Пример #1
0
        public async Task ToTimeString_Called_0_Times()
        {
            //Setup
            var parser = new Mock <ITimeParser>();

            parser.Setup(p => p.ToTimeString(It.IsAny <TimeModel>())).Returns(It.IsAny <string>());
            lineModels.Clear();

            //Operation
            ITimeFileWriter reader = new TimeFileWriter(parser.Object);
            await reader.WriteToFile(fileToWrite, lineModels.OrderBy(c => c.DataSet));

            //Assertions
            parser.Verify(p => p.ToTimeString(It.IsAny <TimeModel>()), Times.Never());
        }
Пример #2
0
        public async Task WriteToFile_Created_File_Line_Count()
        {
            //Setup
            var parser = new Mock <ITimeParser>();

            parser.Setup(p => p.ToTimeString(It.IsAny <TimeModel>())).Returns(It.IsAny <string>());

            //Operation
            ITimeFileWriter reader = new TimeFileWriter(parser.Object);
            await reader.WriteToFile(fileToWrite, lineModels.OrderBy(c => c.DataSet));

            //Assertions
            var lines = File.ReadAllLines(fileToWrite);

            Assert.AreEqual(lines.Length, lineModels.Count() + 1);
        }
Пример #3
0
        public async Task WriteToFile_File_Got_Created()
        {
            //Setup
            var parser = new Mock <ITimeParser>();

            parser.Setup(p => p.ToTimeString(It.IsAny <TimeModel>())).Returns(It.IsAny <string>());

            //Operation
            ITimeFileWriter reader = new TimeFileWriter(parser.Object);
            await reader.WriteToFile(fileToWrite, lineModels.OrderBy(c => c.DataSet));

            //Assertions
            bool fileExists = File.Exists(fileToWrite);

            Assert.AreEqual(fileExists, true);
        }