예제 #1
0
        public void Stores_File_Correctly_When_Correct_Data_Given()
        {
            rootPathProviderMock.Expect(x => x.GetRootPath())
            .Repeat.Once()
            .Return(GetBasePath());

            applicationSettingsMock.Expect(x => x.FileUploadDirectory)
            .Repeat.Once()
            .Return(string.Empty);

            var fileName = "person.txt";

            var fileContent = new StringBuilder()
                              .AppendLine("FirstName;LastName;BirthDate")
                              .AppendLine("Philipp;Wagner;1986/05/12")
                              .AppendLine("Max;Mustermann;2014/01/01");

            Assert.AreEqual(true, Create(fileName, fileContent.ToString()));

            using (var fileReader = new FileStream(GetAbsolutePath(fileName), FileMode.Open))
            {
                var fileUploadResult = handler.HandleUpload(fileName, fileReader).Result;

                Assert.AreEqual(true, Exists(fileUploadResult.Identifier));
                Assert.AreEqual(true, Delete(fileUploadResult.Identifier));
            }

            Assert.AreEqual(true, Delete(fileName));
        }