public void SettingCurrencyProfileProviderToNullWillThrow() { // Fixture setup var fixture = new ControllerFixture(); var sut = fixture.CreateAnonymous <BasketController>(); CurrencyProfileService nullCurrencyProfileService = null; // Exercise system and verify outcome Assert.Throws <ArgumentNullException>(() => sut.CurrencyProfileService = nullCurrencyProfileService); // Teardown }
public void DefaultCurrencyProfileServiceIsCorrect() { // Fixture setup var fixture = new ControllerFixture(); var sut = fixture.Build <BasketController>() .OmitAutoProperties() .With(s => s.ControllerContext) .CreateAnonymous(); // Exercise system CurrencyProfileService result = sut.CurrencyProfileService; // Verify outcome Assert.IsAssignableFrom <DefaultCurrencyProfileService>(result); // Teardown }
public void CurrencyProfileSerivceIsWellBehavedWritableProperty() { // Fixture setup var fixture = new ControllerFixture(); var sut = fixture.Build <BasketController>() .OmitAutoProperties() .CreateAnonymous(); var expectedCurrencyProfileService = new Mock <CurrencyProfileService>().Object; // Exercise system sut.CurrencyProfileService = expectedCurrencyProfileService; CurrencyProfileService result = sut.CurrencyProfileService; // Verify outcome Assert.Equal <CurrencyProfileService>(expectedCurrencyProfileService, result); // Teardown }
public async Task CurrenciesCodeParam_SubmittedHttpClient_ReturnsCurrencyProfile() { //arrange var currencyCode = "USD"; var testJson = "{ \"base\": \"GBP\" }"; var currencyProfileHttpRequestServiceMock = new Mock <ICurrencyProfileHttpRequestService>(); currencyProfileHttpRequestServiceMock.Setup(currencyRequest => currencyRequest.CurrencyProfileResponse(currencyCode)).ReturnsAsync(testJson); CurrencyProfileService currencyProfileService = new CurrencyProfileService( currencyProfileHttpRequestServiceMock.Object); //act var currencyProfile = await currencyProfileService.CurrencyProfile("USD"); //assert Assert.IsInstanceOf <CurrencyProfile>(currencyProfile); }