public void GetWhichChanged_FirstHasTwoEvents_FirstChanged()
        {
            Stamp first  = new Stamp();
            Stamp second = first.Fork();

            first.CreateEvent();
            first.CreateEvent();

            Assert.AreEqual(ChangeOccurredIn.FirstObject, ChangeEvaluator.GetWhichChanged(first, second));
        }
        public void GetConflictingItems_ConflictExists_ConflictAddedToSyncResult()
        {
            // Create conflicting items
            Guid id          = Guid.NewGuid();
            var  serverStamp = new Stamp();
            var  clientStamp = serverStamp.Fork();

            serverStamp.CreateEvent();
            clientStamp.CreateEvent();
            var serverItem = new TestItem {
                Id = id, Stamp = serverStamp
            };
            var clientItem = new TestItem {
                Id = id, Stamp = clientStamp
            };

            // Arrange server repository to return server item
            var repository = Mocking.MockAndBind <IRepository <TestItem, Guid> >(_container);

            Mock.Arrange(() => repository.Find(id)).Returns(serverItem);

            // Arrange client sync request
            ISyncRequest <Guid> syncRequest = new SyncRequest <TestItem, Guid> {
                new SyncItem <Guid>(clientItem)
            };

            var target = new SyncResult <TestItem, Guid>(_container);

            target.GetConflictingItems(syncRequest);

            Assert.IsTrue(target.ConflictingItems.Contains(serverItem));
        }
        public void GetWhichChanged_SecondHasEvent_SecondChanged()
        {
            Stamp first  = new Stamp();
            Stamp second = first.Fork();

            second.CreateEvent();

            Assert.AreEqual(ChangeOccurredIn.SecondObject, ChangeEvaluator.GetWhichChanged(first, second));
        }
        public void GetWhichChanged_FirstHasEventThenJoinedToSecond_Neither()
        {
            Stamp first  = new Stamp();
            Stamp second = first.Fork();

            first.CreateEvent();
            second.Join(first);

            Assert.AreEqual(ChangeOccurredIn.Neither, ChangeEvaluator.GetWhichChanged(first, second));
        }
        public void GetWhichChanged_BothHaveEvent_Both()
        {
            Stamp first  = new Stamp();
            Stamp second = first.Fork();

            first.CreateEvent();
            second.CreateEvent();

            Assert.AreEqual(ChangeOccurredIn.Both, ChangeEvaluator.GetWhichChanged(first, second));
        }
        public void Fork_EventValue1_BothWithEventValue1()
        {
            var target = new Stamp();

            target.CreateEvent();
            var newStamp = target.Fork();

            Assert.AreEqual(1, target.Event.Value);
            Assert.AreEqual(1, newStamp.Event.Value);
        }
        public void GetWhichChanged_BothChangedButJoinedBetweenEvents_Neither()
        {
            Stamp first  = new Stamp();
            Stamp second = first.Fork();

            first.CreateEvent();
            second.Join(first.Peek());
            second.CreateEvent();
            first.Join(second.Peek());

            Assert.AreEqual(ChangeOccurredIn.Neither, ChangeEvaluator.GetWhichChanged(first, second));
        }