public void InitialiseLoadsTheSpaceCorrectlyForMb()
 {
     var server = mocks.DynamicMock<ICruiseServer>();
     var extension = new DiskSpaceMonitorExtension();
     var configuration = new ExtensionConfiguration();
     configuration.Items = new XmlElement[] {
         CreateSizeElement("Mb", 100, "C:\\")
     };
     extension.Initialise(server, configuration);
     Assert.AreEqual(104857600, extension.RetrieveMinimumSpaceRequired("C:\\"));
 }
        public void IntegrationIsSuccessfulWhenSufficientSpace()
        {
            // Initialise the file system
            var fileSystem = mocks.DynamicMock<IFileSystem>();
            SetupResult.For(fileSystem.GetFreeDiskSpace("c:\\"))
                .Return(104857600);

            // Initialise the server
            var server = mocks.DynamicMock<ICruiseServer>();
            SetupResult.For(server.RetrieveService(typeof(IFileSystem)))
                .Return(fileSystem);
            server.IntegrationStarted += null;
            LastCall.IgnoreArguments();
            var eventRaiser = LastCall.GetEventRaiser();

            // Initialise the extension
            var extension = new DiskSpaceMonitorExtension();
            var configuration = new ExtensionConfiguration();
            configuration.Items = new XmlElement[] {
                CreateSizeElement("Mb", 1, "C:\\")
            };
            mocks.ReplayAll();

            // Run the actual test
            extension.Initialise(server, configuration);
            var args = new IntegrationStartedEventArgs(null, "Project 1");
            eventRaiser.Raise(null, args);
            Assert.AreEqual(IntegrationStartedEventArgs.EventResult.Continue, args.Result);
        }
 public void InitialiseThrowsAnErrorForUnknownUnit()
 {
     var server = mocks.DynamicMock<ICruiseServer>();
     var extension = new DiskSpaceMonitorExtension();
     var configuration = new ExtensionConfiguration();
     configuration.Items = new XmlElement[] {
         CreateSizeElement("garbage", 100, "C:\\")
     };
     Assert.That(delegate { extension.Initialise(server, configuration); },
                 Throws.TypeOf<ArgumentOutOfRangeException>());
 }
 public void InitialiseThrowsAnErrorWithNoDrives()
 {
     var server = mocks.DynamicMock<ICruiseServer>();
     var extension = new DiskSpaceMonitorExtension();
     var configuration = new ExtensionConfiguration();
     configuration.Items = new XmlElement[] {
     };
     Assert.That(delegate { extension.Initialise(server, configuration); },
                 Throws.TypeOf<ArgumentOutOfRangeException>());
 }
        public void StartAndAbortDoesNothing()
        {
            var extension = new DiskSpaceMonitorExtension();
            var serverMock = this.mocks.StrictMock<ICruiseServer>();
            var config = new ExtensionConfiguration();

            this.mocks.ReplayAll();
            extension.Start();
            extension.Abort();

            this.mocks.VerifyAll();
        }