Skip to content

Commit

Permalink
Test version consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellperry committed Jan 19, 2024
1 parent f9ee294 commit 819fc24
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Jinaga.Test/Specifications/ProjectionVersioningTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,21 @@ public async Task CanReadVersionTwoFieldFromVersionOneFact()
var jinagaClient = JinagaTest.Create();
var site = await jinagaClient.Fact(new Model.Site(new User("Michael"), "michaelperry.net"));
var contentV1 = await jinagaClient.Fact(new Model.Content(site, "index.html"));
var originalHash = jinagaClient.Hash(contentV1);

var contentCreatedAtForSite = Given<Model.Site>.Match((site, facts) =>
from content in facts.OfType<Model.ContentV2>()
where content.site == site
select new
{
content.createdAt
content.createdAt,
hash = jinagaClient.Hash(content)
}
);
var contentCreatedAt = await jinagaClient.Query(contentCreatedAtForSite, site);

contentCreatedAt.Should().ContainSingle().Which.createdAt.Should().BeNull();
contentCreatedAt.Should().ContainSingle().Which.hash.Should().Be(originalHash);
}

[Fact]
Expand All @@ -58,18 +61,21 @@ public async Task CanReadVersionTwoFieldFromVersionTwoFact()
var jinagaClient = JinagaTest.Create();
var site = await jinagaClient.Fact(new Model.Site(new User("Michael"), "michaelperry.net"));
var contentV2 = await jinagaClient.Fact(new Model.ContentV2(site, new DateTime(2021, 1, 1).ToUniversalTime()));
var originalHash = jinagaClient.Hash(contentV2);

var contentCreatedAtForSite = Given<Model.Site>.Match((site, facts) =>
from content in facts.OfType<Model.ContentV2>()
where content.site == site
select new
{
content.createdAt
content.createdAt,
hash = jinagaClient.Hash(content)
}
);
var contentCreatedAt = await jinagaClient.Query(contentCreatedAtForSite, site);

contentCreatedAt.Should().ContainSingle().Which.createdAt.Should().Be(new DateTime(2021, 1, 1).ToUniversalTime());
contentCreatedAt.Should().ContainSingle().Which.hash.Should().Be(originalHash);
}

[Fact]
Expand All @@ -78,17 +84,20 @@ public async Task CanReadVersionOneFieldFromVersionTwoFact()
var jinagaClient = JinagaTest.Create();
var site = await jinagaClient.Fact(new Model.Site(new User("Michael"), "michaelperry.net"));
var contentV2 = await jinagaClient.Fact(new Model.ContentV2(site, new DateTime(2021, 1, 1)));
var originalHash = jinagaClient.Hash(contentV2);

var contentPathForSite = Given<Model.Site>.Match((site, facts) =>
from content in facts.OfType<Model.Content>()
where content.site == site
select new
{
content.path
content.path,
hash = jinagaClient.Hash(content)
}
);
var contentPath = await jinagaClient.Query(contentPathForSite, site);

contentPath.Should().ContainSingle().Which.path.Should().Be("");
contentPath.Should().ContainSingle().Which.hash.Should().Be(originalHash);
}
}

0 comments on commit 819fc24

Please sign in to comment.