コード例 #1
0
        public void UserApplication_IsValid_ShouldReturnTrue()
        {
            // Arrange
            var CustomerFixture    = new CustomersTestsFixture();
            var UserProfileFixture = new UserProfilesTestsFixture();

            var userApp = Fixture.GetUserAppService();
            var user    = Fixture.GenerateValidUserToAdd();

            Fixture.CustomerAppServiceMock.Setup(c => c.GetById(1)).Returns(CustomerFixture.GenerateValidCustomerToQuery());
            Fixture.UserProfileAppServiceMock.Setup(c => c.GetById(3)).Returns(UserProfileFixture.GenerateValidUserProfile());

            // Act
            EntityValidationResult validation = userApp.IsValid(user);

            // Assert Fluent Assertions
            validation.Status.Should().BeTrue();
            validation.ValidationMessages.Should().HaveCount(c => c == 0);
        }
コード例 #2
0
        public void UserApplication_IsValid_ShouldReturnFalseAndMessageInvalidProfile()
        {
            var CustomerFixture    = new CustomersTestsFixture();
            var UserProfileFixture = new UserProfilesTestsFixture();

            // Arrange
            var userApp = Fixture.GetUserAppService();
            var user    = Fixture.GenerateUserWithInvalidProfile();

            Fixture.CustomerAppServiceMock.Setup(c => c.GetById(1)).Returns(CustomerFixture.GenerateValidCustomerToQuery());
            Fixture.UserProfileAppServiceMock.Setup(c => c.GetById(1)).Returns(UserProfileFixture.GenerateValidUserProfile());

            // Act
            EntityValidationResult validation = userApp.IsValid(user);

            // Assert Fluent Assertions
            validation.Status.Should().BeFalse();
            validation.ValidationMessages.Should().HaveCount(c => c == 1);
            validation.ValidationMessages[0].Should().Be("Profile Not Found");
        }
コード例 #3
0
        public void UserApplication_IsValid_ShouldReturnFalseAndMessageUsernameAlreadyExists()
        {
            // Arrange
            var CustomerFixture    = new CustomersTestsFixture();
            var UserProfileFixture = new UserProfilesTestsFixture();

            var userApp = Fixture.GetUserAppService();
            var user    = Fixture.GenerateValidUserWithUserId0();

            Fixture.UserRepositoryMock.Setup(c => c.GetByUsername("ricardo.goes")).Returns(Fixture.GenerateValidUserToQuery());
            Fixture.CustomerAppServiceMock.Setup(c => c.GetById(1)).Returns(CustomerFixture.GenerateValidCustomerToQuery());
            Fixture.UserProfileAppServiceMock.Setup(c => c.GetById(3)).Returns(UserProfileFixture.GenerateValidUserProfile());

            // Act
            EntityValidationResult validation = userApp.IsValid(user);

            // Assert Fluent Assertions
            validation.Status.Should().BeFalse();
            validation.ValidationMessages.Should().HaveCount(c => c == 1);
            validation.ValidationMessages[0].Should().Be("Username already exists");
        }