示例#1
0
 public void BehaviorTest_LockLog_WriterfunctionsCalled()
 {
     _uut.LogDoorLocked(123);
     //Tester den fulde log entry Datetime er i et format så tests ikke fejler med tid
     _streamWriter.Received(1).Write("Log entry: ");
     _streamWriter.Received(1).WriteLine($"{DateTime.Now.ToShortTimeString()} {DateTime.Now.ToLongDateString()}");
     _streamWriter.Received(1).WriteLine("Charging station locked using RFID: 123");
     _streamWriter.Received(1).WriteLine("-------------------------------------------------------");
     _streamWriter.Received(1).Close();
 }
示例#2
0
        public void Debug_Log_Call_Shoould_Write_File_Expected_Message__And_Path()
        {
            string message         = LoggerProvider.CreateLogMessage(MessageLength.Normal);
            string expectedMessage = $"{_dateTimeProviderMock.UtcNow} [DEBUG] {message}";

            using (var stream = _streamFactoryMock.Create())
            {
                var streamLogger = new StreamLogger(stream, _dateTimeProviderMock, _streamWriterMock);
                streamLogger.Log(LogLevel.Debug, message);
                _streamWriterMock.Received().Writeline(Arg.Any <Stream>(), Arg.Is(expectedMessage));
            }
        }
示例#3
0
        public async Task WriteFile_WhenExecuted_ShouldCallStreamWriter()
        {
            var path = "path";

            var list = new List <string>
            {
                "I",
                "am",
                "an",
                "item"
            };

            await _mockWriter.WriteLineAsync(Arg.Is(path), Arg.Is(list));

            await _sut.WriteFile(path, list);

            await _mockWriter.Received(1)
            .WriteLineAsync(path, list);
        }