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

            Assert.AreEqual(ChangeOccurredIn.Neither, ChangeEvaluator.GetWhichChanged(first, second));
        }
        // POST api/<controller>
        public HttpResponseMessage Post(JoinNodes nodesToJoin)
        {
            Node nodeToReturn = null;

            switch (ChangeEvaluator.GetWhichChanged(nodesToJoin.Node1.Stamp, nodesToJoin.Node2.Stamp))
            {
            case ChangeOccurredIn.Both:
                nodeToReturn                = nodesToJoin.Node1;
                nodeToReturn.SomeValue0     = -1;
                nodeToReturn.HasConflict    = true;
                nodeToReturn.ConflictValue1 = nodesToJoin.Node1.SomeValue0;
                nodeToReturn.ConflictValue2 = nodesToJoin.Node2.SomeValue0;
                nodeToReturn.Stamp.Join(nodesToJoin.Node2.Stamp);
                break;

            case ChangeOccurredIn.FirstObject:
                nodeToReturn = nodesToJoin.Node1;
                nodeToReturn.Stamp.Join(nodesToJoin.Node2.Stamp);
                break;

            case ChangeOccurredIn.SecondObject:
                nodeToReturn = nodesToJoin.Node2;
                nodeToReturn.Stamp.Join(nodesToJoin.Node1.Stamp);
                break;

            case ChangeOccurredIn.Neither:
                nodeToReturn = nodesToJoin.Node1;
                nodeToReturn.Stamp.Join(nodesToJoin.Node2.Stamp);
                break;
            }

            return(Request.CreateResponse(HttpStatusCode.OK, nodeToReturn));
        }
        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_FirstHasTwoEvents_FirstChanged()
        {
            Stamp first  = new Stamp();
            Stamp second = first.Fork();

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

            Assert.AreEqual(ChangeOccurredIn.FirstObject, 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 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));
        }