Exemplo n.º 1
0
        public async void ExistingScriptWithChangedFileNameIsUpdated()
        {
            var existingWithNewFileName = TestFactory.Copy(existingScript);

            existingWithNewFileName.FileName = "changed";

            cmd = new SaveInputScript(storageProvider, scriptProvider, existingWithNewFileName);
            await cmd.Execute();

            var result = cmd.Result;

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);

            scriptProviderMock.Verify(v => v.Scripts, Times.AtLeastOnce);
            scriptProviderMock.Verify(v => v.AddOrUpdate(It.Is <InputScript>(s => s.Equals(existingWithNewFileName)), true), Times.Once);
            storageProviderMock.Verify(v => v.UpdateScript(It.Is <InputScript>(s => s.Equals(existingWithNewFileName)), It.IsAny <InputScript>()), Times.Once);
            storageProviderMock.Verify(v => v.SaveScript(It.Is <InputScript>(s => s.Equals(existingWithNewFileName))), Times.Never);
            storageProviderMock.Verify(v => v.LoadAllSourceFiles(It.Is <InputScript>(s => s.Equals(existingWithNewFileName))), Times.Once);
        }
        public void Setup()
        {
            fileSystemUtilsMock = new Mock <IFileSystemUtils>();
            fileSystemUtilsMock.Setup(f => f.DirectoryExists(It.IsAny <string>())).Returns(true);

            inputConfigProviderMock = new Mock <IInputConfigProvider>();
            inputConfigProvider     = inputConfigProviderMock.Object;

            appConfigProviderMock = new Mock <IAppConfigProvider>();
            appConfigProvider     = appConfigProviderMock.Object;

            storageProviderMock = new Mock <IStorageProvider>();
            storageProviderMock.Setup(s => s.SaveInputConfiguration(It.IsAny <InputConfiguration>()));
            storageProviderMock.Setup(s => s.UpdateInputConfiguration(It.IsAny <InputConfiguration>(), It.IsAny <InputConfiguration>()));
            storageProvider = storageProviderMock.Object;

            newConfiguration = new InputConfiguration
            {
                FileName = "test.json"
            };
            oldConfiguration          = TestFactory.Copy(newConfiguration);
            oldConfiguration.FileName = "test2.json";
        }