public void BinaryHttp_Serialization_GetManyRequest_SingleFact()
        {
            Client.GetManyRequest clientRequest = new Client.GetManyRequest
            {
                ClientGuid     = "{96E5C2E2-1345-482E-9668-6009DCDC0E70}",
                Domain         = "TestDomain",
                TimeoutSeconds = 30,
                PivotTree      = CreateTreeWithSingleFact(),
                PivotIds       = new List <Client.FactTimestamp>
                {
                    new Client.FactTimestamp {
                        FactId = 42, TimestampId = 28768
                    }
                }
            };

            var serverRequest = WriteAndRead(
                w => clientRequest.Write(w),
                r => Server.BinaryRequest.Read(r) as Server.GetManyRequest);

            Assert.IsNotNull(serverRequest);
            Assert.AreEqual(1, serverRequest.PivotTree.Facts.Count());
            Assert.AreEqual(42, serverRequest.PivotTree.Facts.ElementAt(0).Id.key);
            IdentifiedFactMemento fact = serverRequest.PivotTree.Facts.ElementAt(0) as IdentifiedFactMemento;

            Assert.IsNotNull(fact);
            Assert.AreEqual("TestModel.Domain", fact.Memento.FactType.TypeName);
            Assert.AreEqual(1, serverRequest.PivotIds.Count());
            Assert.AreEqual(42, serverRequest.PivotIds.ElementAt(0).FactId);
            Assert.AreEqual(28768, serverRequest.PivotIds.ElementAt(0).TimestampId);
        }
        public void BinaryHttp_Serialization_GetManyRequest_MultipleFacts()
        {
            Client.GetManyRequest clientRequest = new Client.GetManyRequest
            {
                ClientGuid     = "{96E5C2E2-1345-482E-9668-6009DCDC0E70}",
                Domain         = "TestDomain",
                TimeoutSeconds = 30,
                PivotTree      = CreateTreeWithMultipleFacts(),
                PivotIds       = new List <Client.FactTimestamp>
                {
                    new Client.FactTimestamp {
                        FactId = 42, TimestampId = 28768
                    }
                }
            };

            var serverRequest = WriteAndRead(
                w => clientRequest.Write(w),
                r => Server.BinaryRequest.Read(r) as Server.GetManyRequest);

            Assert.IsNotNull(serverRequest);
            Assert.AreEqual(2, serverRequest.PivotTree.Facts.Count());
            Assert.AreEqual(42, serverRequest.PivotTree.Facts.ElementAt(0).Id.key);
            Assert.AreEqual(73, serverRequest.PivotTree.Facts.ElementAt(1).Id.key);
            IdentifiedFactMemento game = serverRequest.PivotTree.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]);
        }
        public void BinaryHttp_Serialization_GetManyRequest_EmptyTree()
        {
            Client.GetManyRequest clientRequest = new Client.GetManyRequest
            {
                ClientGuid     = "{96E5C2E2-1345-482E-9668-6009DCDC0E70}",
                Domain         = "TestDomain",
                TimeoutSeconds = 30,
                PivotTree      = new FactTreeMemento(0),
                PivotIds       = new List <Client.FactTimestamp>()
            };

            var serverRequest = WriteAndRead(
                w => clientRequest.Write(w),
                r => Server.BinaryRequest.Read(r) as Server.GetManyRequest);

            Assert.IsNotNull(serverRequest);
            Assert.AreEqual(Guid.Parse("{96E5C2E2-1345-482E-9668-6009DCDC0E70}"), serverRequest.ClientGuid);
            Assert.AreEqual("TestDomain", serverRequest.Domain);
            Assert.AreEqual(30, serverRequest.TimeoutSeconds);
            Assert.AreEqual(0, serverRequest.PivotTree.Facts.Count());
            Assert.AreEqual(0, serverRequest.PivotIds.Count());
        }