public async Task GetProducerAmendmentsHistoryCSVHandler_WithBrandNamesLongerThanMaxLength_ThrowsException() { var authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build(); var context = A.Fake <WeeeContext>(); var storedProcedures = A.Fake <IStoredProcedures>(); var csvWriterFactory = A.Fake <CsvWriterFactory>(); A.CallTo(() => context.StoredProcedures) .Returns(storedProcedures); var csvData1 = new ProducerAmendmentsHistoryCSVData { ProducerName = "Producer1", DateRegistered = new DateTime(2000, 3, 2, 11, 25, 13), BrandNames = new string('A', GetMembersDetailsCsvHandler.MaxBrandNamesLength + 1) }; var csvData2 = new ProducerAmendmentsHistoryCSVData { ProducerName = "Producer1", DateRegistered = new DateTime(2001, 7, 12, 16, 12, 54), BrandNames = "BrandName2" }; var csvData3 = new ProducerAmendmentsHistoryCSVData { ProducerName = "Producer1", DateRegistered = new DateTime(2002, 8, 5, 9, 3, 28), BrandNames = new string('A', GetMembersDetailsCsvHandler.MaxBrandNamesLength + 1) }; A.CallTo(() => storedProcedures .SpgProducerAmendmentsCSVDataByPRN(A <string> ._)) .Returns(new List <ProducerAmendmentsHistoryCSVData> { csvData1, csvData2, csvData3 }); var handler = new GetProducerAmendmentsHistoryCSVHandler(authorization, context, csvWriterFactory); var request = new GetProducerAmendmentsHistoryCSV("PRN"); // Act var exception = await Record.ExceptionAsync(() => handler.HandleAsync(request)); // Assert Assert.NotNull(exception); Assert.Contains("02/03/2000 11:25:13", exception.Message); Assert.Contains("05/08/2002 09:03:28", exception.Message); Assert.Contains("brand names", exception.Message); }
public async Task GetProducerAmendmentsHistoryCSVHandler_WithBrandNamesLongerThanMaxLength_ThrowsException() { var authorization = new AuthorizationBuilder().AllowInternalAreaAccess().Build(); var context = A.Fake<WeeeContext>(); var storedProcedures = A.Fake<IStoredProcedures>(); var csvWriterFactory = A.Fake<CsvWriterFactory>(); A.CallTo(() => context.StoredProcedures) .Returns(storedProcedures); var csvData1 = new ProducerAmendmentsHistoryCSVData { ProducerName = "Producer1", DateRegistered = new DateTime(2000, 3, 2, 11, 25, 13), BrandNames = new string('A', GetMembersDetailsCsvHandler.MaxBrandNamesLength + 1) }; var csvData2 = new ProducerAmendmentsHistoryCSVData { ProducerName = "Producer1", DateRegistered = new DateTime(2001, 7, 12, 16, 12, 54), BrandNames = "BrandName2" }; var csvData3 = new ProducerAmendmentsHistoryCSVData { ProducerName = "Producer1", DateRegistered = new DateTime(2002, 8, 5, 9, 3, 28), BrandNames = new string('A', GetMembersDetailsCsvHandler.MaxBrandNamesLength + 1) }; A.CallTo(() => storedProcedures .SpgProducerAmendmentsCSVDataByPRN(A<string>._)) .Returns(new List<ProducerAmendmentsHistoryCSVData> { csvData1, csvData2, csvData3 }); var handler = new GetProducerAmendmentsHistoryCSVHandler(authorization, context, csvWriterFactory); var request = new GetProducerAmendmentsHistoryCSV("PRN"); // Act var exception = await Record.ExceptionAsync(() => handler.HandleAsync(request)); // Assert Assert.NotNull(exception); Assert.Contains("02/03/2000 11:25:13", exception.Message); Assert.Contains("05/08/2002 09:03:28", exception.Message); Assert.Contains("brand names", exception.Message); }