Exemple #1
0
        public void SystemMonitor_NotValidDumpFile_CallsCorruptFileLoggingServiceCorrectly()          // changes done by me
        {
            FileExtensionManager          theFileExtensionManager       = new FileExtensionManager(); // Fix this
            FakeCorruptFileLoggingService mockCorruptFileLoggingService = new FakeCorruptFileLoggingService();
            FakeCrashLoggingService       mockCrashLoggingService       = new FakeCrashLoggingService();
            FakeEmailService mockEmailService = new FakeEmailService();
            SystemMonitor    theMonitor       = new SystemMonitor(theFileExtensionManager, mockCrashLoggingService, null, mockCorruptFileLoggingService);

            theMonitor.ProcessDump("Filename.txt");
            StringAssert.Contains("Dump file is corrupt", mockCorruptFileLoggingService.theMessage);// check if Corrupt File logging service called
        }
Exemple #2
0
        public void SystemMonitor_ValidDumpFile_DoesNotCallCorruptFileLoggingService()
        { // I want to test that the CrashLogger is called correctly so its an interaction test.
          //This test needs one stub and one mock. Assert against the mock to see if it's called properly.
          // Arrange
            FileExtensionManager          theFileExtensionManager       = new FileExtensionManager();
            FakeCrashLoggingService       mockCrashLoggingService       = new FakeCrashLoggingService();
            FakeCorruptFileLoggingService mockCorruptFileLoggingService = new FakeCorruptFileLoggingService();
            SystemMonitor theMonitor = new SystemMonitor(theFileExtensionManager, mockCrashLoggingService, null, mockCorruptFileLoggingService); //inject the fakes

            // Act
            theMonitor.ProcessDump("ValidFile.dmp");
            // Assert
            Assert.IsNull(mockCorruptFileLoggingService.theMessage); // This test is about checking the CrashLoggingService is not called
        }
Exemple #3
0
        public void SystemMonitor_NotValidDumpFile_CallsCorruptFileLoggingServiceCorrectlyThrowsException() // changes done by me
        {                                                                                                   // I want to test that the CrashLogger is called correctly so its an interaction test.
          //This test needs one stub and one mock. Assert against the mock to see if it's called properly.
          // Arrange
            FileExtensionManager          theFileExtensionManager       = new FileExtensionManager();
            FakeCrashLoggingService       mockCrashLoggingService       = new FakeCrashLoggingService();
            FakeEmailService              mockEmailService              = new FakeEmailService();
            FakeCorruptFileLoggingService stubCorruptFileLoggingService = new FakeCorruptFileLoggingService();

            stubCorruptFileLoggingService.WillThrow = new Exception("fake exception");                                                                       // prime it with a fake exception
            SystemMonitor theMonitor = new SystemMonitor(theFileExtensionManager, mockCrashLoggingService, mockEmailService, stubCorruptFileLoggingService); //inject the fakes

            // Act
            theMonitor.ProcessDump("NotValidFile.txt");
            // Assert
            StringAssert.Contains("fake exception", mockEmailService.theBody); // This test is about checking that the CrashLoggingService called
            // so we are 'asking' the fake 'were you called?'
        }