public void OutputBuilderTests_BuildProductLines_NullProductValue_ThrowsException() { //arrange var sut = new OutputBuilder(); IMinMax range = GetMinMaxMock(1, 5, 3); // Irrelevant to this test IAccumulatedProduct[] mockData = { GetAccumulatedProductMock("a", new double[0]), GetAccumulatedProductMock("b", null), GetAccumulatedProductMock("c", new double[0]), }; IAccumulatedProducts mockDatas = GetAccumulatedProductsMock(range, mockData); bool exceptionThrown = false; string exceptionMessage = ""; //act try { sut.BuildProductLines(mockDatas); } catch (InvalidOperationException e) { exceptionThrown = true; exceptionMessage = e.Message; } //assert Assert.IsTrue(exceptionThrown); Assert.AreEqual("Accumulated product 1 value: not allowed to be null", exceptionMessage); }
public void OutputBuilderTests_BuildProductLines_CorrectProductName_StringStartsWithProductNameAndAComma() { //arrange var sut = new OutputBuilder(); IMinMax range = GetMinMaxMock(1, 5, 3); // Irrelevant to this test string names = "Working"; IAccumulatedProduct[] mockData = { GetAccumulatedProductMock(names, new double[0]) }; IAccumulatedProducts mockDatas = GetAccumulatedProductsMock(range, mockData); //act List <string> outputString = sut.BuildProductLines(mockDatas); //assert Assert.AreEqual("Working, ", outputString.First()); }
public void OutputBuilderTests_BuildProductLines_NullInput_ThrowsException() { //arrange var sut = new OutputBuilder(); bool exceptionThrown = false; string exceptionMessage = ""; //act try { sut.BuildProductLines(null); } catch (ArgumentNullException e) { exceptionThrown = true; exceptionMessage = e.Message; } //assert Assert.IsTrue(exceptionThrown); Assert.AreEqual("Value cannot be null." + Environment.NewLine + "Parameter name: products", exceptionMessage); }
public void OutputBuilderTests_BuildProductLines_IfNoDataIn_ThrowsException() { //arrange var sut = new OutputBuilder(); IMinMax range = GetMinMaxMock(1, 5, 3); // Irrelevant to this test IAccumulatedProducts mockDatas = GetAccumulatedProductsMock(range, new IAccumulatedProduct[] { }); bool exceptionThrown = false; string exceptionMessage = ""; //act try { sut.BuildProductLines(mockDatas); } catch (InvalidOperationException e) { exceptionThrown = true; exceptionMessage = e.Message; } //assert Assert.IsTrue(exceptionThrown); Assert.AreEqual("The list of accumulated products is not allowed to be empty", exceptionMessage); }