public void ExportToCSV() { var report = new FaultLogger().GetReport(); StringBuilder str = new StringBuilder(); str.AppendLine("MeasurementID" + "," + "Current" + "," + "FaultID" + "," + "PrimaryLocations" + "," + "SecondaryLocations" + "," + "Timestamp"); foreach (var item in report) { str.AppendLine(item.ID + "," + item.Current + "," + item.FaultID + "," + item.PrimaryLocations.Replace(',', ' ') + "," + item.SecondaryLocations.Replace(',', ' ') + "," + item.TimeStamp); } string fileName = "Report_" + "20160503_" + Guid.NewGuid() + ".csv"; System.IO.File.WriteAllText(@"D:\" + fileName, str.ToString()); }
public void When_I_Capture_A_Fault_Then_The_System_Should_Create_A_New_Fault() { //Arrange var geoCode = new GeocodeLocation(LocationType.GeoCode) { Latitude = -26.0606438M, Longtude = 27.9452808M }; var fault = new Mock<Fault>(); fault.Setup(x => x.Type).Returns(FaultType.TrafficLight); fault.Setup(x => x.FaultReference).Returns("1"); fault.Setup(x => x.Geocode).Returns(geoCode); fault.Setup(x => x.Id).Returns(1); var faultRepositoryMock = new Mock<IFaultRepository>(); var faultLogger = new FaultLogger(faultRepositoryMock.Object); // action faultLogger.Save(fault.Object); // assert faultRepositoryMock.Verify(x => x.Save(fault.Object), Times.Once()); }