public async Task StateApplication_AddNewStateService_ShouldHasSuccess() { //Arrange var stateViewModel = _stateTestFixture.GenerateValidStateViewModel(); var mocker = new AutoMocker(); var applicationServiceState = mocker.CreateInstance <ApplicationServiceState>(); //Act await applicationServiceState.AddAsync(stateViewModel); //Assert mocker.GetMock <IServiceState>().Verify(s => s.AddAsyncUow(It.IsAny <State>()), Times.Once); mocker.GetMock <IMapperState>().Verify(m => m.ViewModelToEntity(It.IsAny <StateViewModel>()), Times.Once); }
internal async Task AddNewStateAsync(int qty) { for (int i = 0; i < qty; i++) { var countryApi = new CountryApiTest(_integrationTestFixture); await countryApi.AddNewCountriesAsync(1, false); var countriesViewModel = await GetAllCountriesAsync(1, 5); var countryViewModel = countriesViewModel.FirstOrDefault(); var stateFixture = new StateTestFixture(); var state = stateFixture.GenerateValidStateViewModel(); state.CountryId = countryViewModel.Id.GetValueOrDefault(); var postResponse = await _integrationTestFixture.Client.PostAsJsonAsync(requestAdd, state); postResponse.EnsureSuccessStatusCode(); } }