Ejemplo n.º 1
0
        public void EntitiesWithDifferentTypeAndDifferentIdAreDifferent()
        {
            var firstEntity  = new TestableEntity();
            var secondEntity = new DifferentEntity();

            Assert.False(firstEntity.Equals(secondEntity));
        }
        public void entity_propertyChanged_event_on_disposed_entity_using_propertyName_should_raise_ObjectDisposedException()
        {
            var expected = "Foo";

            var target = new TestableEntity();

            target.Dispose();
            target.RaisePropertyChanged(expected);
        }
Ejemplo n.º 3
0
        public void EntitiesWithSameTypeAndSameIdAreTheSame()
        {
            var firstEntity  = new TestableEntity();
            var secondEntity = new TestableEntity();

            secondEntity.Id = firstEntity.Id;

            Assert.True(firstEntity.Equals(secondEntity));
        }
Ejemplo n.º 4
0
        public void IsValidOnNullInstanceThrowsArgumentNullException()
        {
            // Arrange
            TestableEntity entity = null;

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(() => entity.IsValid());
        }
Ejemplo n.º 5
0
        public void ValidateWithInvalidObjectThrowsException()
        {
            // Arrange
            var entity = TestableEntity.CreateInvalidEntity();

            // Act

            // Assert
            Assert.Throws <ValidationException>(() => entity.Validate());
        }
Ejemplo n.º 6
0
        public void ValidateWithValidObjectDoesNotThrowException()
        {
            // Arrange
            var entity = TestableEntity.CreateValidEntity();

            // Act

            // Assert
            Assert.DoesNotThrow(entity.Validate);
        }
Ejemplo n.º 7
0
        public void IsValidWithValidObjectReturnsTrue()
        {
            // Arrange
            var entity = TestableEntity.CreateValidEntity();

            // Act
            var isValid = entity.IsValid();

            // Assert
            Assert.True(isValid);
        }
Ejemplo n.º 8
0
        public void WhenNull_ShouldNotCompare()
        {
            // arrange
            var id = _fixture.Create <Id <TestableEntity> >();
            var a  = TestableEntity.Create(id, _fixture.Create <Name>());

            // act
            var actual = a == null;

            // assert
            actual.Should().BeFalse();
        }
        public void entity_propertyChanged_event_using_propertyName_raised_with_expected_values()
        {
            var expected = "Foo";
            var actual   = string.Empty;

            var target = new TestableEntity();

            target.PropertyChanged += (s, e) => { actual = e.PropertyName; };
            target.RaisePropertyChanged(expected);

            actual.Should().Be.EqualTo(expected);
        }
Ejemplo n.º 10
0
        public void WhenSameId_ShouldCompare()
        {
            // arrange
            var id = _fixture.Create <Id <TestableEntity> >();
            var a  = TestableEntity.Create(id, _fixture.Create <Name>());
            var b  = TestableEntity.Create(id, _fixture.Create <Name>());

            // act
            var actual = a == b;

            // assert
            actual.Should().BeTrue();
        }
Ejemplo n.º 11
0
        public void WhenSameId_ShouldBeEqualObjects()
        {
            // arrange
            var id = _fixture.Create <Id <TestableEntity> >();
            var a  = TestableEntity.Create(id, _fixture.Create <Name>());
            var b  = TestableEntity.Create(id, _fixture.Create <Name>());

            // act
            var actual = a.Equals((object)b);

            // assert
            actual.Should().BeTrue();
        }
Ejemplo n.º 12
0
        public void WhenDifferentId_ShouldCompareShouldNotBeTrue()
        {
            // arrange
            var number = _fixture.Create <Name>();
            var a      = TestableEntity.Create(_fixture.Create <Id <TestableEntity> >(), number);
            var b      = TestableEntity.Create(_fixture.Create <Id <TestableEntity> >(), number);

            // act
            var actual = a != b;

            // assert
            actual.Should().BeTrue();
        }
Ejemplo n.º 13
0
        public void WhenDifferentId_ShouldNotBeEqual()
        {
            // arrange
            var number = _fixture.Create <Name>();
            var a      = TestableEntity.Create(_fixture.Create <Id <TestableEntity> >(), number);
            var b      = TestableEntity.Create(_fixture.Create <Id <TestableEntity> >(), number);

            // act
            var actual = a.Equals(b);

            // assert
            actual.Should().BeFalse();
        }
Ejemplo n.º 14
0
        public void WhenGuidId_ShouldBeOfTypeId_Key()
        {
            // arrange
            var expected = _fixture.Create <Guid>();
            var id       = Id <TestableEntity> .Create(expected);

            var name = _fixture.Create <Name>();

            // act
            var actual = TestableEntity.Create(id, name);

            // assert
            actual.Id
            .Should()
            .BeOfType <Id <TestableEntity> >();
        }
Ejemplo n.º 15
0
        public void WhenGuidId_ShouldContainGuidId()
        {
            // arrange
            var expected = _fixture.Create <Guid>();
            var id       = Id <TestableEntity> .Create(expected);

            var name = _fixture.Create <Name>();

            // act
            var actual = TestableEntity.Create(id, name);

            // assert
            actual.Id
            .ToString()
            .Should()
            .Be(expected.ToString());
        }
Ejemplo n.º 16
0
        public void NewEntityHasId()
        {
            var entity = new TestableEntity();

            Assert.False(string.IsNullOrEmpty(entity.Id));
        }