public void RecordCalculation_PassInCalculation_Calls_LoggerRecordCalculation_with_calculation()
 {
     var mockLogger = new Mock<ILog>();
     var aCalulation = new Calculation();
     var controller = new TransactionRecorderController(mockLogger.Object);
     controller.RecordCalculation(aCalulation);
     mockLogger.Verify(x => x.RecordCalculation(aCalulation), Times.Once);
 }
Exemplo n.º 2
0
 public void RecordCalculation(Calculation calculation)
 {
     using (var sw = new StreamWriter(streamToWriteTo))
     {
         sw.WriteLine(string.Format("{0},{1},{2},{3},{4}",clock.Now(),calculation.Probability1,calculation.Probability2,calculation.Answer,calculation.Operation));
         sw.Close();
     }
 }
Exemplo n.º 3
0
        public void RecordCalculation_ProvideCalcuation_Should_populate_stream_with_csv()
        {
            var calculation = new Calculation { Answer = 2.1, Operation = "theOperation", Probability1 = 0.3, Probability2 = 0.6 };
            var memoryStream = new MemoryStream();
            var mockClock = new Mock<IClock>();

            mockClock.SetReturnsDefault(new DateTime(2000, 1, 10, 10, 12, 30));

            var logger = new Logger(memoryStream, mockClock.Object);
            logger.RecordCalculation(calculation);

            byte[] buffer = memoryStream.ToArray();
            var result = Encoding.UTF8.GetString(buffer, 0, buffer.Length);
            Assert.AreEqual("10/01/2000 10:12:30,0.3,0.6,2.1,theOperation\r\n", result);
        }