コード例 #1
0
        public void AddAndRemoveProduceNothing()
        {
            var add    = _changes.Single(c => c.Reason == ChangeReason.Add);
            var remove = _changes.Single(c => c.Reason == ChangeReason.Remove);

            var result = ChangesReducer.Reduce(add, remove);

            result.HasValue.Should().Be(false);
        }
コード例 #2
0
        public void RemoveAndAddProduceUpdate()
        {
            var remove = _changes.Single(c => c.Reason == ChangeReason.Remove);
            var add    = _changes.Single(c => c.Reason == ChangeReason.Add);

            var result   = ChangesReducer.Reduce(remove, add);
            var expected = new Change <Person, string>(ChangeReason.Update, _testEntity.Key, add.Current, remove.Current, add.CurrentIndex, remove.CurrentIndex);

            result.Value.Should().Be(expected);
        }
コード例 #3
0
        public void AddAndUpdateProduceAdd()
        {
            var updatedEntity = new Person(_testEntity.Key, 55);
            var newIndex      = _testIndex + 1;

            var add    = new Change <Person, string>(ChangeReason.Add, _testEntity.Key, _testEntity, _testIndex);
            var update = new Change <Person, string>(ChangeReason.Update, _testEntity.Key, updatedEntity, add.Current, newIndex, _testIndex);

            var result   = ChangesReducer.Reduce(add, update);
            var expected = new Change <Person, string>(ChangeReason.Add, _testEntity.Key, updatedEntity, newIndex);

            result.Value.Should().Be(expected);
        }
コード例 #4
0
        public void TwoUpdatesProduceUpdate()
        {
            var updatedEntityOne = new Person(_testEntity.Key, 55);
            var updatedEntityTwo = new Person(_testEntity.Key, 33);

            var newIndexOne = _testIndex + 1;
            var newIndexTwo = _testIndex + 2;

            var firstUpdate  = new Change <Person, string>(ChangeReason.Update, _testEntity.Key, updatedEntityOne, _testEntity, newIndexOne, _testIndex);
            var secondUpdate = new Change <Person, string>(ChangeReason.Update, _testEntity.Key, updatedEntityTwo, updatedEntityOne, newIndexTwo, newIndexOne);

            var result   = ChangesReducer.Reduce(firstUpdate, secondUpdate);
            var expected = new Change <Person, string>(ChangeReason.Update, _testEntity.Key, updatedEntityTwo, _testEntity, newIndexTwo, _testIndex);

            result.Value.Should().Be(expected);
        }
コード例 #5
0
        public void RefreshIsBeingOverridenByAnything(Change <Person, string> refresh, Change <Person, string> other)
        {
            var result = ChangesReducer.Reduce(refresh, other);

            result.Value.Should().Be(other);
        }
コード例 #6
0
        public void NoneGetsOverridenByAnything(Change <Person, string> c)
        {
            var result = ChangesReducer.Reduce(Optional <Change <Person, string> > .None, c);

            result.Value.Should().Be(c);
        }
コード例 #7
0
        public void RemoveOverridesAnythingButAdd(Change <Person, string> remove, Change <Person, string> other)
        {
            var result = ChangesReducer.Reduce(other, remove);

            result.Value.Should().Be(remove);
        }