public void Should_create_correct_ProductSorter_for_given_sortOption(SortOptionType sortOption, Type productSorterType, SortOrder sortOrder = SortOrder.Ascending) { // Arrange var mockedShopperHistoryService = Mock.Of <IShopperHistoryService>(); var productSorterFactory = new ProductSorterFactory(mockedShopperHistoryService); // Act var productSorter = productSorterFactory.Create(sortOption); // Assert Assert.Equal(productSorter.GetType(), productSorterType); Assert.Equal(productSorter.SortOrder, sortOrder); }
public void GetProductSorter_ProvidedSortOptionUnavailable_ThrowsInvalidOperationException() { // Arrange var soterMock = new Mock <IProductSortStrategy>(); soterMock.Setup(x => x.SortOption).Returns(SortOption.Low); var productSorterFactory = new ProductSorterFactory(new List <IProductSortStrategy> { soterMock.Object }); // Act & Assert Assert.Throws <InvalidOperationException>(() => productSorterFactory.GetProductSorter(SortOption.High)); }
public void GetProductSorter_ProvidedSortOptionAvailable_ReturnsSorter(SortOption sortOption) { // Arrange var soterMock = new Mock <IProductSortStrategy>(); soterMock.Setup(x => x.SortOption).Returns(sortOption); var productSorterFactory = new ProductSorterFactory(new List <IProductSortStrategy> { soterMock.Object }); // Act var productSorter = productSorterFactory.GetProductSorter(sortOption); // Assert productSorter.Should().NotBeNull(); productSorter.SortOption.Should().Be(sortOption); }
public ProductSorterFactoryTests() { // Arrange _apiResourceProxy = Substitute.For <IApiResourceProxy>(); _sut = new ProductSorterFactory(_apiResourceProxy); }