예제 #1
0
        public void CopyTestFile_should_save_existing_test_file_with_new_name(bool expectedResult)
        {
            // given
            const string sourceFilename = "I AM YO FILENAME BRO.FML";
            const string targetFilename = "<insert virus script here so I can break Chris' computer...>";

            var testRepositoryMock = new Mock <ITestRepository>();

            var expectedExistingTestFile = new TestFile {
                Filename = sourceFilename
            };

            testRepositoryMock
            .Setup(x => x.GetTestFile(sourceFilename))
            .Returns(expectedExistingTestFile);

            testRepositoryMock
            .Setup(x => x.CreateTestFile(expectedExistingTestFile))
            .Returns(expectedResult);

            // when
            var  controller = new TestsController(testRepositoryMock.Object, null);
            bool result     = controller.CopyTestFile(sourceFilename, targetFilename);

            // then
            Assert.That(result, Is.EqualTo(expectedResult));
            Assert.That(expectedExistingTestFile.Filename, Is.EqualTo(targetFilename));
        }