Example #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
        }
Example #2
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?'
        }
Example #3
0
        public void SystemMonitor_ValidDumpFileCallsCrashLoggingServiceWhichThrowsException_CallsEmailService()
        { //Want to test that if the CrashLogger throws an exception then the EmailService is called correctly so its an interaction test.
          // This test needs two stubs and one mock. Assert against the mock.
          // Arrange
            FileExtensionManager    theFileExtensionManager = new FileExtensionManager();
            FakeCrashLoggingService stubCrashLoggingService = new FakeCrashLoggingService();

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

            // Act
            theMonitor.ProcessDump("ValidFile.dmp");
            // Assert
            StringAssert.Contains("*****@*****.**", mockEmailService.theTo);
            StringAssert.Contains("crashLoggingService Web service threw exception", mockEmailService.theSubject);
            StringAssert.Contains("fake exception", mockEmailService.theBody);
        }