Exemple #1
0
        public void Add_Before_Registration_Uses_Default_Comparer_And_Succeeds_When_Keys_Match_But_Different_Objects()
        {
            // Arrange
            var entity = new SomeEntityType {
                GroupKey = "1", Id = Guid.NewGuid(), SomeString = "Hello", SomeInt = 1
            };
            var sameIdsEntity = new SomeEntityType {
                GroupKey = entity.GroupKey, Id = entity.Id, SomeString = "World", SomeInt = 2
            };

            // Act
            _sut.Add(entity);
            _sut.Add(sameIdsEntity);

            // Assert
            _sut.Entities <SomeEntityType>().Count.Should().Be(2);
            var entityFromStore        = _sut.Entities <SomeEntityType>().First(x => x.Equals(entity));
            var sameIdsEntityFromStore = _sut.Entities <SomeEntityType>().First(x => x.Equals(sameIdsEntity));

            entityFromStore.Should().NotBeSameAs(sameIdsEntityFromStore);
        }