예제 #1
0
        public async Task Execute_InsertPerson()
        {
            var person = PersonFaker.Get(StatusEnumeration.Active).Generate().MapToAddRequest();

            var result = await instance.Execute(person);

            result.Should().NotBe(Guid.Empty);
        }
        public async Task Execute_ReturnsFalse_WhenPersonDoNotExist()
        {
            var person = PersonFaker.Get().Generate().MapToUpdateRequest();

            personRepository.Setup(x => x.Update(It.IsAny <Person>()))
            .ReturnsAsync(false);

            var result = await instance.Execute(person);

            result.Should().BeFalse();
        }
예제 #3
0
        public async Task Execute_ReturnsPeople()
        {
            var people = PersonFaker.Get().Generate(3);

            personRepository.Setup(x => x.GetAll())
            .ReturnsAsync(people);

            var result = await instance.Execute();

            result.Should().BeEquivalentTo(people.MapToResponse());
        }
        public async Task Execute_ReturnsTrue_WhenSuccess()
        {
            var person = PersonFaker.Get().Generate().MapToUpdateRequest();

            personRepository.Setup(x => x.Update(It.IsAny <Person>()))
            .ReturnsAsync(true);

            var result = await instance.Execute(person);

            result.Should().BeTrue();
        }
예제 #5
0
        public async Task GetAll_ReturnsPeople()
        {
            var people = PersonFaker.Get().Generate(3);

            getPeopleUseCase.Setup(x => x.Execute())
            .ReturnsAsync(people.MapToResponse());

            var response = await instance.GetAll();

            response.Result.Should().BeOfType <OkObjectResult>()
            .Which.Value.Should().BeEquivalentTo(people.MapToViewModel());
        }
예제 #6
0
        public async Task Update_ReturnsNotFound_WhenUpdateFailed()
        {
            var id     = Guid.NewGuid();
            var person = PersonFaker.Get().Generate().MapToViewModel();

            updatePersonUseCase.Setup(x => x.Execute(It.IsAny <PersonUpdateRequest>()))
            .ReturnsAsync(false);

            var response = await instance.Update(id, person);

            response.Result.Should().BeOfType <NotFoundResult>();
        }
예제 #7
0
        public async Task Update_ReturnsId_WhenUpdatedSuccessfully()
        {
            var id     = Guid.NewGuid();
            var person = PersonFaker.Get().Generate().MapToViewModel();

            updatePersonUseCase.Setup(x => x.Execute(It.IsAny <PersonUpdateRequest>()))
            .ReturnsAsync(true);

            var response = await instance.Update(id, person);

            response.Result.Should().BeOfType <OkObjectResult>()
            .Which.Value.Should().Be(id);
        }
예제 #8
0
        public async Task Get_ReturnsPerson()
        {
            var id     = Guid.NewGuid();
            var person = PersonFaker.Get().Generate();

            getPersonUseCase.Setup(x => x.Execute(id))
            .ReturnsAsync(person.MapToResponse());

            var response = await instance.Get(id);

            response.Result.Should().BeOfType <OkObjectResult>()
            .Which.Value.Should().BeEquivalentTo(person.MapToViewModel());
        }