public void BinaryHttp_Serialization_GetManyResponse_SingleFact() { var serverResponse = new Server.GetManyResponse { FactTree = CreateTreeWithSingleFact(), PivotIds = new List <FactTimestamp> { new FactTimestamp { FactId = 42, TimestampId = 67676 } } }; var clientResponse = WriteAndRead( w => serverResponse.Write(w), r => Client.BinaryResponse.Read(r) as Client.GetManyResponse); Assert.IsNotNull(clientResponse); Assert.AreEqual(1, clientResponse.FactTree.Facts.Count()); Assert.AreEqual(42, clientResponse.FactTree.Facts.ElementAt(0).Id.key); IdentifiedFactMemento fact = clientResponse.FactTree.Facts.ElementAt(0) as IdentifiedFactMemento; Assert.IsNotNull(fact); Assert.AreEqual("TestModel.Domain", fact.Memento.FactType.TypeName); Assert.AreEqual(1, clientResponse.PivotIds.Count()); Assert.AreEqual(42, clientResponse.PivotIds.ElementAt(0).FactId); Assert.AreEqual(67676, clientResponse.PivotIds.ElementAt(0).TimestampId); }
public void BinaryHttp_Serialization_GetManyResponse_EmptyTree() { var serverResponse = new Server.GetManyResponse { FactTree = new FactTreeMemento(0), PivotIds = new List <FactTimestamp>() }; var clientResponse = WriteAndRead( w => serverResponse.Write(w), r => Client.BinaryResponse.Read(r) as Client.GetManyResponse); Assert.IsNotNull(clientResponse); Assert.AreEqual(0, clientResponse.FactTree.Facts.Count()); Assert.AreEqual(0, clientResponse.PivotIds.Count()); }
public void BinaryHttp_Serialization_GetManyResponse_MultipleFacts() { var serverResponse = new Server.GetManyResponse { FactTree = CreateTreeWithMultipleFacts(), PivotIds = new List <FactTimestamp> { new FactTimestamp { FactId = 42, TimestampId = 67676 } } }; var clientResponse = WriteAndRead( w => serverResponse.Write(w), r => Client.BinaryResponse.Read(r) as Client.GetManyResponse); Assert.IsNotNull(clientResponse); Assert.AreEqual(2, clientResponse.FactTree.Facts.Count()); Assert.AreEqual(42, clientResponse.FactTree.Facts.ElementAt(0).Id.key); Assert.AreEqual(73, clientResponse.FactTree.Facts.ElementAt(1).Id.key); IdentifiedFactMemento game = clientResponse.FactTree.Facts.ElementAt(1) as IdentifiedFactMemento; Assert.IsNotNull(game); Assert.AreEqual("TestModel.Game", game.Memento.FactType.TypeName); Assert.AreEqual(1, game.Memento.Predecessors.Count()); Assert.AreEqual(42, game.Memento.Predecessors.ElementAt(0).ID.key); Assert.AreEqual("TestModel.Game", game.Memento.Predecessors.ElementAt(0).Role.DeclaringType.TypeName); Assert.AreEqual("domain", game.Memento.Predecessors.ElementAt(0).Role.RoleName); Assert.IsTrue(game.Memento.Predecessors.ElementAt(0).IsPivot); Assert.AreEqual(4, game.Memento.Data.Length); Assert.AreEqual(1, game.Memento.Data[0]); Assert.AreEqual(2, game.Memento.Data[1]); Assert.AreEqual(3, game.Memento.Data[2]); Assert.AreEqual(4, game.Memento.Data[3]); }