Esempio n. 1
0
            public async void ShouldDeleteAndReturnTheDeletedNinja()
            {
                //Arrange
                var clanName      = "Some clan name";
                var ninjaKey      = "SomeNinjaKey";
                var expectedNinja = new Ninja();

                ClanServiceMock
                .Setup(x => x.IsClanExistsAsync(clanName))
                .ReturnsAsync(true);
                NinjaRepositoryMock
                .Setup(x => x.ReadOneAsync(clanName, ninjaKey))
                .ReturnsAsync(expectedNinja)
                .Verifiable();
                NinjaRepositoryMock
                .Setup(x => x.DeleteAsync(clanName, ninjaKey))
                .ReturnsAsync(expectedNinja)
                .Verifiable();

                //Act
                var result = await ServiceUnderTest.DeleteAsync(clanName, ninjaKey);

                //Assert
                Assert.Same(expectedNinja, result);
                NinjaRepositoryMock.Verify(x => x.ReadOneAsync(clanName, ninjaKey), Times.Once);
                NinjaRepositoryMock.Verify(x => x.DeleteAsync(clanName, ninjaKey), Times.Once);
            }
Esempio n. 2
0
            public async Task ReadOneAsync_Gets_Maps_And_Returns_A_Workout_When_ApiCall_Returns_Workout()
            {
                // Arrange
                const int id = 1;
                var       expectedWorkout = new Workout {
                    Name = "Test workout 01", Id = id
                };
                var expectedWorkoutViewModel = new WorkoutViewModel {
                    Name = "Test workout 01", Id = id
                };

                HttpClientMock
                .Setup(x => x.GetStringAsync(It.IsAny <string>()))
                .ReturnsAsync(JsonConvert.SerializeObject(expectedWorkout))
                .Verifiable();
                MapperMock
                .Setup(x => x.Map <Workout, WorkoutViewModel>(It.IsAny <Workout>()))
                .Returns(expectedWorkoutViewModel)
                .Verifiable();

                // Act
                var result = await ServiceUnderTest.ReadOneAsync(id);

                // Assert
                Assert.Same(expectedWorkoutViewModel, result);
                HttpClientMock.Verify(x => x.GetStringAsync(It.IsAny <string>()), Times.Once);
                MapperMock.Verify(x => x.Map <Workout, WorkoutViewModel>(It.IsAny <Workout>()), Times.Once);
            }
Esempio n. 3
0
            public async void ShouldThrowNinjaNotFoundExceptionWhenNinjaDoesNotExist()
            {
                //Arrange
                var clanName      = "Some clan name";
                var ninjaKey      = "SomeNinjaKey";
                var expectedNinja = new Ninja {
                    Clan = new Clan {
                        Name = clanName
                    }, Key = ninjaKey
                };

                NinjaRepositoryMock
                .Setup(x => x.ReadOneAsync(clanName, ninjaKey))
                .ThrowsAsync(new NinjaNotFoundException(clanName, ninjaKey))
                .Verifiable();
                NinjaRepositoryMock
                .Setup(x => x.DeleteAsync(clanName, ninjaKey))
                .Verifiable();

                //Act & Assert
                await Assert.ThrowsAsync <NinjaNotFoundException>(() => ServiceUnderTest.UpdateAsync(expectedNinja));

                NinjaRepositoryMock.Verify(x => x.ReadOneAsync(clanName, ninjaKey), Times.Once);
                NinjaRepositoryMock.Verify(x => x.UpdateAsync(expectedNinja), Times.Never);
            }
Esempio n. 4
0
            public async void ShouldReturnAllNinjas()
            {
                //Arrange
                var expectedNinjas = new Ninja[]
                {
                    new Ninja {
                        Name = "Test Ninja 1"
                    },
                    new Ninja {
                        Name = "Test Ninja 2"
                    },
                    new Ninja {
                        Name = "Test Ninja 3"
                    }
                };

                NinjaRepositoryMock
                .Setup(x => x.ReadAllAsync())
                .ReturnsAsync(expectedNinjas);

                //Act
                var result = await ServiceUnderTest.ReadAllAsync();

                //Assert
                Assert.Same(expectedNinjas, result);
            }
Esempio n. 5
0
            public async void Should_throw_NinjaNotFoundException_when_ninja_does_not_exist()
            {
                // Arrange
                const string clanName = "Some clan name";
                const string ninjaKey = "Some ninja key";

                NinjaRepositoryMock
                .Setup(x => x.DeleteAsync(clanName, ninjaKey))
                .Verifiable();
                NinjaRepositoryMock
                .Setup(x => x.ReadOneAsync(clanName, ninjaKey))
                .ReturnsAsync(default(Ninja))
                .Verifiable();

                // Act & Assert
                await Assert.ThrowsAsync <NinjaNotFoundException>(() => ServiceUnderTest.DeleteAsync(clanName, ninjaKey));

                // Make sure UpdateAsync is never hit
                NinjaRepositoryMock
                .Verify(x => x.DeleteAsync(clanName, ninjaKey), Times.Never);

                // Make sure we read the ninja from the repository before attempting an update.
                NinjaRepositoryMock
                .Verify(x => x.ReadOneAsync(clanName, ninjaKey), Times.Once);
            }
Esempio n. 6
0
            public async void ShouldCreateAndReturnTheCreatedNinja()
            {
                //Arrange
                var clanName      = "Some clan name";
                var expectedNinja = new Ninja {
                    Name = "Test Ninja 1", Clan = new Clan {
                        Name = clanName
                    }
                };

                ClanServiceMock
                .Setup(x => x.IsClanExistsAsync(expectedNinja.Clan.Name))
                .ReturnsAsync(true)
                .Verifiable();
                NinjaRepositoryMock
                .Setup(x => x.CreateAsync(expectedNinja))
                .ReturnsAsync(expectedNinja)
                .Verifiable();

                //Act
                var result = await ServiceUnderTest.CreateAsync(expectedNinja);

                //Assert
                Assert.Same(expectedNinja, result);
                ClanServiceMock.Verify(x => x.IsClanExistsAsync(clanName), Times.Once);
                NinjaRepositoryMock.Verify(x => x.CreateAsync(expectedNinja), Times.Once);
            }
Esempio n. 7
0
            public async void Should_throw_NinjaNotFoundException_when_ninja_does_not_exist()
            {
                // Arrange
                const string ninjaKey        = "SomeKey";
                const string clanKey         = "Some clan";
                var          unexistingNinja = new Ninja {
                    Key = ninjaKey, Clan = new Clan {
                        Name = clanKey
                    }
                };

                NinjaRepositoryMock
                .Setup(x => x.UpdateAsync(unexistingNinja))
                .Verifiable();
                NinjaRepositoryMock
                .Setup(x => x.ReadOneAsync(clanKey, ninjaKey))
                .ReturnsAsync(default(Ninja))
                .Verifiable();
                ClanServiceMock
                .Setup(x => x.IsClanExistsAsync(clanKey))
                .ReturnsAsync(true);

                // Act & Assert
                await Assert.ThrowsAsync <NinjaNotFoundException>(() => ServiceUnderTest.UpdateAsync(unexistingNinja));

                // Make sure UpdateAsync is never hit
                NinjaRepositoryMock
                .Verify(x => x.UpdateAsync(unexistingNinja), Times.Never);

                // Make sure we read the ninja from the repository before attempting an update.
                NinjaRepositoryMock
                .Verify(x => x.ReadOneAsync(clanKey, ninjaKey), Times.Once);
            }
Esempio n. 8
0
            public async Task ShouldReturnAllClans()
            {
                // Arrange
                var expectedClans = new ReadOnlyCollection <Clan>(new List <Clan>
                {
                    new Clan {
                        Name = "My Clan"
                    },
                    new Clan {
                        Name = "Your Clan"
                    },
                    new Clan {
                        Name = "His Clan"
                    }
                });

                ClanRepositoryMock
                .Setup(x => x.ReadAllAsync())
                .ReturnsAsync(expectedClans);

                // Act
                var result = await ServiceUnderTest.ReadAllAsync();

                // Assert
                Assert.Same(expectedClans, result);
            }
Esempio n. 9
0
            public async void Should_create_and_return_the_created_Ninja()
            {
                // Arrange
                const string clanName      = "Some clan name";
                var          expectedNinja = new Ninja {
                    Clan = new Clan {
                        Name = clanName
                    }
                };

                NinjaRepositoryMock
                .Setup(x => x.CreateAsync(expectedNinja))
                .ReturnsAsync(expectedNinja)
                .Verifiable();
                ClanServiceMock
                .Setup(x => x.IsClanExistsAsync(clanName))
                .ReturnsAsync(true);

                // Act
                var result = await ServiceUnderTest.CreateAsync(expectedNinja);

                // Assert
                Assert.Same(expectedNinja, result);
                NinjaRepositoryMock.Verify(x => x.CreateAsync(expectedNinja), Times.Once);
            }
Esempio n. 10
0
            public async void Should_update_and_return_the_updated_Ninja()
            {
                // Arrange
                const string ninjaKey      = "Some key";
                const string clanKey       = "Some clan";
                var          expectedNinja = new Ninja
                {
                    Key  = ninjaKey,
                    Clan = new Clan {
                        Name = clanKey
                    }
                };

                NinjaRepositoryMock
                .Setup(x => x.ReadOneAsync(clanKey, ninjaKey))
                .ReturnsAsync(expectedNinja);
                NinjaRepositoryMock
                .Setup(x => x.UpdateAsync(expectedNinja))
                .ReturnsAsync(expectedNinja)
                .Verifiable();
                ClanServiceMock
                .Setup(x => x.IsClanExistsAsync(clanKey))
                .ReturnsAsync(true);

                // Act
                var result = await ServiceUnderTest.UpdateAsync(expectedNinja);

                // Assert
                Assert.Same(expectedNinja, result);
                NinjaRepositoryMock.Verify(x => x.UpdateAsync(expectedNinja), Times.Once);
            }
Esempio n. 11
0
            public async void GetAsyncByName()
            {
                // Arrange
                var expectedCustomers = new Page <Customer>
                {
                    Items     = new Customer[] { customers[5] },
                    TotalSize = 1
                };

                CustomersRepositoryMock
                .Setup(x => x.GetAsyncByName("6"))
                .ReturnsAsync(expectedCustomers.Items);

                foreach (Customer customer in customers)
                {
                    VehiclesRepositoryMock
                    .Setup(x => x.GetByCustomerId(customer.Id, SearchVehicleStatus.Any))
                    .ReturnsAsync(customer.Vehicles);
                }
                // Act
                var result = await ServiceUnderTest.GetAsyncByName("6", pagingOptions);

                // Assert
                Assert.True(EqualityHelper.SamePageOfCustomers(expectedCustomers, result));
            }
Esempio n. 12
0
        public void TestSetBit([Range(1, 8)] int bitPosition)
        {
            var expected = 1ul << bitPosition;
            var actual   = ServiceUnderTest.SetBit(0, (ushort)bitPosition);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 13
0
            public async void Should_return_error_with_message()
            {
                // Arrange
                var authors = new List <AuthorListItem>
                {
                    new AuthorListItem
                    {
                        Name        = "Peter Piper",
                        Nationality = "Austrian"
                    },
                    new AuthorListItem
                    {
                        Name        = "Spiderman",
                        Nationality = "American"
                    }
                };
                var result = new Result <IList <AuthorListItem> >();

                result.AddError("f**k off");
                ListAllAuthorsQueryMock
                .Setup(x => x.Execute())
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.ListAllAuthorsAsync();

                // Assert
                Assert.Same(result, serviceResult);
                Assert.Null(serviceResult.Value);
                Assert.Same(result.Errors.FirstOrDefault(), serviceResult.Errors.FirstOrDefault());
            }
Esempio n. 14
0
            public async Task ReadAllAsync_Returns_All_Workouts()
            {
                // Arrange
                var expectedWorkouts = new[]
                {
                    new Workout {
                        Name = "Test workout 01"
                    },
                    new Workout {
                        Name = "Test workout 02"
                    },
                    new Workout {
                        Name = "Test workout 03"
                    }
                };

                WorkoutRepositoryMock
                .Setup(x => x.ReadAllAsync())
                .ReturnsAsync(expectedWorkouts);

                // Act
                var result = await ServiceUnderTest.ReadAllAsync();

                // Assert
                Assert.Same(expectedWorkouts, result);
            }
Esempio n. 15
0
            public async void Should_throw_a_ClanNotFoundException_when_clan_does_not_exist()
            {
                // Arrange
                const string ninjaKey        = "SomeKey";
                const string clanKey         = "Some clan";
                var          unexistingNinja = new Ninja {
                    Key = ninjaKey, Clan = new Clan {
                        Name = clanKey
                    }
                };

                NinjaRepositoryMock
                .Setup(x => x.UpdateAsync(unexistingNinja))
                .Verifiable();
                ClanServiceMock
                .Setup(x => x.IsClanExistsAsync(clanKey))
                .ReturnsAsync(false);

                // Act & Assert
                await Assert.ThrowsAsync <ClanNotFoundException>(() => ServiceUnderTest.UpdateAsync(unexistingNinja));

                // Make sure UpdateAsync is never called
                NinjaRepositoryMock
                .Verify(x => x.UpdateAsync(unexistingNinja), Times.Never);
            }
Esempio n. 16
0
            public async Task CreateAsync_Maps_Posts_And_Throws_HttpRequestException_When_ApiCall_Fails()
            {
                // Arrange
                var expectedWorkoutViewModel = new WorkoutViewModel {
                    Name = "Test workout 01"
                };
                var expectedWorkout = new Workout {
                    Name = "Test workout 01"
                };

                MapperMock
                .Setup(x => x.Map <WorkoutViewModel, Workout>(expectedWorkoutViewModel))
                .Returns(expectedWorkout)
                .Verifiable();
                HttpClientMock
                .Setup(x => x.PostEntityAsync(It.IsAny <string>(), expectedWorkout))
                .ReturnsAsync(new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.InternalServerError,
                    Content    = new StringContent("Content as string")
                })
                .Verifiable();

                // Act, Assert
                await Assert.ThrowsAsync <HttpRequestException>(() =>
                                                                ServiceUnderTest.CreateAsync(expectedWorkoutViewModel));

                MapperMock.Verify(x => x.Map <WorkoutViewModel, Workout>(expectedWorkoutViewModel), Times.Once);
                HttpClientMock.Verify(x => x.PostEntityAsync(It.IsAny <string>(), expectedWorkout), Times.Once);
            }
Esempio n. 17
0
            public async Task CreateAsync_Maps_Posts_And_Completes_When_ApiCall_Succeeds()
            {
                // Arrange
                var expectedWorkoutViewModel = new WorkoutViewModel {
                    Name = "Test workout 01"
                };
                var expectedWorkout = new Workout {
                    Name = "Test workout 01"
                };

                MapperMock
                .Setup(x => x.Map <WorkoutViewModel, Workout>(expectedWorkoutViewModel))
                .Returns(expectedWorkout)
                .Verifiable();
                HttpClientMock
                .Setup(x => x.PostEntityAsync(It.IsAny <string>(), expectedWorkout))
                .ReturnsAsync(new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.OK,
                    Content    = new StringContent("Content as string")
                })
                .Verifiable();

                // Act
                await ServiceUnderTest.CreateAsync(expectedWorkoutViewModel);

                // Assert
                MapperMock.Verify(x => x.Map <WorkoutViewModel, Workout>(expectedWorkoutViewModel), Times.Once);
                HttpClientMock.Verify(x => x.PostEntityAsync(It.IsAny <string>(), expectedWorkout), Times.Once);
            }
Esempio n. 18
0
            public async void Should_return_error_with_message()
            {
                // Arrange
                var genres = new List <Genre>
                {
                    new Genre {
                        Name = "Katherine Man"
                    },
                    new Genre {
                        Name = "Matherine Kan"
                    }
                };
                var result = new Result <IList <Genre> >();

                result.AddError("f**k off");
                ListAllGenresQueryMock
                .Setup(x => x.Execute())
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.ListAllGenresAsync();

                // Assert
                Assert.Same(result, serviceResult);
                Assert.Null(serviceResult.Value);
                Assert.Same(result.Errors.FirstOrDefault(), serviceResult.Errors.FirstOrDefault());
            }
Esempio n. 19
0
        public void Migration_Old_Preferences()
        {
            _preferences.Setup(x => x.Get(PreferenceConstants.SoberDate, DateTime.Today))
            .Returns(new DateTime(2020, 12, 31));

            _preferences.Setup(x => x.Get(PreferenceConstants.NotificationsEnabled, false))
            .Returns(true);

            _preferences.Setup(x => x.Get(PreferenceConstants.NotificationTime, default(DateTime)))
            .Returns(new DateTime(2020, 12, 31, 9, 0, 0));

            ServiceUnderTest.MigrateOldPreferences();

            _preferences.Verify(x => x.Get(PreferenceConstants.SoberDate, DateTime.Today), Times.Once);
            _preferences.Verify(x => x.Get(PreferenceConstants.NotificationsEnabled, false), Times.Once);
            _preferences.Verify(x => x.Get(PreferenceConstants.NotificationTime, default(DateTime)), Times.Once);

            _preferences.Verify(x => x.Set(PreferenceConstants.SoberDate, new DateTime(2020, 12, 31), PreferenceConstants.PreferenceSharedName),
                                Times.Once);
            _preferences.Verify(x => x.Set(PreferenceConstants.NotificationsEnabled, true, PreferenceConstants.PreferenceSharedName),
                                Times.Once);
            _preferences.Verify(x => x.Set(PreferenceConstants.NotificationTime, new DateTime(2020, 12, 31, 9, 0, 0), PreferenceConstants.PreferenceSharedName),
                                Times.Once);
            _preferences.Verify(x => x.Clear(), Times.Once);
        }
Esempio n. 20
0
            public async Task DeleteIssueAsync_Where_SaveChangesAsync_Fails_Should__return_a_IssueNotCreatedException_Test()
            {
                // Arrange

                var expectedLog = $"Delete Issue: {IssueToDeleteDto.Id} Failed!";

                RepositoryWrapperMock
                .Setup(x => x.Issue.GetIssueByIdAsync(IssueToDeleteDto.Id))
                .ReturnsAsync(Issues[0]).Verifiable();

                RepositoryWrapperMock
                .Setup(x => x.SaveAsync())
                .Throws(new Exception("Save Changes Failed")).Verifiable();

                // Act

                await Assert.ThrowsAsync <IssueNotDeletedException>(() => ServiceUnderTest.DeleteIssueAsync(IssueToDeleteDto));

                // Assert

                LoggerMock.VerifyLog(LogLevel.Error, expectedLog);
                RepositoryWrapperMock.Verify(x => x.SaveAsync(), Times.Once);
                RepositoryWrapperMock
                .Verify(x => x.Issue.GetIssueByIdAsync(IssueToDeleteDto.Id), Times.Once);
            }
Esempio n. 21
0
            public async void Should_return_ok_with_Nationality()
            {
                // Arrange
                var Nationality = new List <Nationality>
                {
                    new Nationality {
                        Name = "Katherine Man"
                    },
                    new Nationality {
                        Name = "Matherine Kan"
                    }
                };
                var result = new Result <IList <Nationality> >(Nationality);

                ListAllNationalitiesQueryMock
                .Setup(x => x.Execute())
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.ListAllNationalitiesAsync();

                // Assert
                Assert.Same(result, serviceResult);
                Assert.NotNull(serviceResult.Value);
                Assert.Same(Nationality.FirstOrDefault(), serviceResult.Value.FirstOrDefault());
            }
Esempio n. 22
0
            public async Task UpdateIssueAsync_Where_SaveChangesAsync_Fails_Should__return_a_IssueNotCreatedException_Test()
            {
                // Arrange

                const int id               = 1;
                var       expectedLog      = $"Updating Issue: {id} Failed!";
                var       issueToUpdateDto = new IssueForUpdateDto
                {
                    Id = 1, IssueDescription = "Test 1 updated", DateAdded = DateTimeOffset.Now
                };

                RepositoryWrapperMock
                .Setup(x => x.Issue.GetIssueByIdAsync(id))
                .ReturnsAsync(Issues[0]).Verifiable();

                RepositoryWrapperMock
                .Setup(x => x.SaveAsync())
                .Throws(new Exception("Save Changes Failed")).Verifiable();

                // Act

                await Assert.ThrowsAsync <IssueNotUpdatedException>(() => ServiceUnderTest.UpdateIssueAsync(issueToUpdateDto));

                // Assert

                LoggerMock.VerifyLog(LogLevel.Error, expectedLog);
                RepositoryWrapperMock.Verify(x => x.SaveAsync(), Times.Once);
                RepositoryWrapperMock
                .Verify(x => x.Issue.GetIssueByIdAsync(id), Times.Once);
            }
Esempio n. 23
0
            public async Task UpdateIssueAsync_Should_Update_and_return_the_specified_Issue_Test()
            {
                // Arrange

                const int id = 1;
                var       issueToUpdateDto = new IssueForUpdateDto()
                {
                    Id = 1, IssueDescription = "Test 1 updated", DateAdded = DateTimeOffset.Now
                };

                RepositoryWrapperMock
                .Setup(x => x.Issue.GetIssueByIdAsync(id))
                .ReturnsAsync(Issues[0]).Verifiable();

                RepositoryWrapperMock
                .Setup(x => x.SaveAsync())
                .Returns(() => Task.Run(() => { return(1); })).Verifiable();

                // Act

                var result = await ServiceUnderTest.UpdateIssueAsync(issueToUpdateDto);

                // Assert

                result.Should().BeTrue();
                RepositoryWrapperMock.Verify(x => x.SaveAsync(), Times.Once);
                RepositoryWrapperMock
                .Verify(x => x.Issue.GetIssueByIdAsync(id), Times.Once);
            }
Esempio n. 24
0
            public async Task CreateIssueAsync_Should_create_and_return_the_specified_Issue_Test()
            {
                // Arrange

                const int id          = 5;
                var       newIssueDto = new IssueForCreationDto
                {
                    Id = 5, IssueDescription = "Test 5", DateAdded = DateTimeOffset.Now
                };

                RepositoryWrapperMock
                .Setup(x => x.Issue.GetIssueByIdAsync(It.IsAny <int>()))
                .ReturnsAsync(default(Issue)).Verifiable();

                RepositoryWrapperMock
                .Setup(x => x.SaveAsync())
                .Returns(() => Task.Run(() => { return(1); })).Verifiable();

                // Act

                var result = await ServiceUnderTest.CreateIssueAsync(newIssueDto);

                // Assert

                result.Should().NotBeNull();
                result.Should().BeOfType <IssueDto>();
                result.Id.Should().Be(id);
                result.IssueDescription.Should().Be(newIssueDto.IssueDescription);
                RepositoryWrapperMock.Verify(x => x.SaveAsync(), Times.Once);
            }
Esempio n. 25
0
            public async Task Deve_Consultar_Por_Cnpj()
            {
                // Arrange

                var listaTransicao = new List <Transacao>();

                listaTransicao.Add(new Transacao {
                    MerchantCnpj = "77404852000179"
                });
                listaTransicao.Add(new Transacao {
                    MerchantCnpj = "77404852000179"
                });
                listaTransicao.Add(new Transacao {
                    MerchantCnpj = "77404852000179"
                });


                transacaoRepositoryMock
                .Setup(x => x.ConsultaPorCnpj(""))
                .ReturnsAsync(listaTransicao);

                // Act
                var result = await ServiceUnderTest.ConsultaPorCnpj("77404852000179");

                // Assert
                Assert.Same(listaTransicao, result);
            }
Esempio n. 26
0
            public async Task Deve_Consultar_Por_Data_e_bandeira()
            {
                // Arrange

                var listaTransicao = new List <Transacao>();

                listaTransicao.Add(new Transacao {
                    MerchantCnpj = "77404852000179", AcquirerName = "Cielo", CardBrandName = "MasterCard", AcquirerAuthorizationDateTime = DateTime.Now
                });
                listaTransicao.Add(new Transacao {
                    MerchantCnpj = "77404852000179", AcquirerName = "Cielo", CardBrandName = "MasterCard", AcquirerAuthorizationDateTime = DateTime.Now
                });
                listaTransicao.Add(new Transacao {
                    MerchantCnpj = "77404852000179", AcquirerName = "Cielo", CardBrandName = "MasterCard", AcquirerAuthorizationDateTime = DateTime.Now
                });


                transacaoRepositoryMock
                .Setup(x => x.ConsultaPorAdquirente("Cielo", "Mastercard"))
                .ReturnsAsync(listaTransicao);

                // Act
                var result = await ServiceUnderTest.ConsultaPorAdquirente("Cielo", "Mastercard");

                // Assert
                Assert.Same(listaTransicao, result);
            }
Esempio n. 27
0
            public async void Should_return_ok_with_books()
            {
                // Arrange
                var books = new List <Book>
                {
                    new Book
                    {
                        Title = "Some book"
                    },
                    new Book
                    {
                        Title = "Another book"
                    }
                };
                var result = new Result <IList <Book> >(books);

                ListAllBooksQueryMock
                .Setup(x => x.Execute())
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.ListAllBooksAsync();

                // Assert
                Assert.Same(result, serviceResult);
                Assert.NotNull(serviceResult.Value);
                Assert.Same(books.FirstOrDefault(), serviceResult.Value.FirstOrDefault());
            }
Esempio n. 28
0
        public void ParseVersion_From_String_Parses_Correctly(string appVersion, string assemblyVersion, string fileVersion, string version, string nuGetPackageVersion, string nuGetFileName)
        {
            //Act
            var model = ServiceUnderTest.ParseAppVersion(appVersion);

            //Assert
            AssertVersionModel(model, assemblyVersion, fileVersion, version, nuGetPackageVersion, nuGetFileName);
        }
Esempio n. 29
0
        public void ParseVersion_From_Context_Throws_When_AppVersion_Does_Not_Exist()
        {
            //Act
            var exception = Assert.Throws <Exception>(() => ServiceUnderTest.ParseAppVersion());

            //Assert
            exception.Message.Should().Be("AppVersion argument missing");
        }
Esempio n. 30
0
        public async Task GetProduct_ShouldReturnProductWithSameID()
        {
            ShopContextMock.Setup(c => c.Products).Returns(TestSetOfProducts.Object);
            var products = await ServiceUnderTest.GetAllProducts();

            Assert.AreEqual(3, products.Count);
            Assert.AreEqual("Product1", products[0].Name);
        }