using System; using System.Collections.Generic; using System.IO; using BroseCumulativeReport; using BroseCumulativeReport.Model; using Microsoft.Extensions.Configuration; using Moq; using Xunit; namespace BroseCumulativeReport.Tests { public class ExcelGeneratorTests { private readonly Mock _mockConfiguration = new(); public ExcelGeneratorTests() { // Setup mock IConfiguration behavior if needed } [Fact] public void GenerateExcel_ShouldCreateFile_WhenProvidedValidInput() { // Arrange var excelGenerator = new ExcelGenerator(_mockConfiguration.Object); string tempFilePath = Path.GetTempFileName(); List mainRows = new List(); // Minimal MainRow data to avoid empty file scenario mainRows.Add(new MainRow { CustomerName = "Customer", CustomerOrderNumber = "Order1", OrderNumber = "OrderNum", OrderDate = DateTime.Today, SalesChannelProductCode = "SCP", ShipperProductCode = "SPC", LastWzNumber = "WZ123", WzQuantity = 1, SendDatesWithQuantity = new List<(DateTime, int)> { (DateTime.Today, 1) }, ChildRows = new List() }); // Act excelGenerator.GenerateExcel(tempFilePath, mainRows); // Assert Assert.True(File.Exists(tempFilePath)); // Cleanup File.Delete(tempFilePath); } //[Fact] // This test requires refactoring ExcelGenerator to allow injection of SMTP client // to mock and verify sending logic without side effects. //public void SendEmail_ShouldSendEmailWithoutExceptions_WhenCalled() //{ // // Arrange // var excelGenerator = new ExcelGenerator(_mockConfiguration.Object); // string dummyFilePath = "dummyfile.xlsx"; // // Act & Assert // var exception = Record.Exception(() => excelGenerator.SendEmail(dummyFilePath)); // Assert.Null(exception); //} } }