Exemplo n.º 1
0
        public void GetRequest_ForStoppedOutside()
        {
            driver.Start();
            driverSC.SetStatus(ServiceControllerStatus.Stopped);

            AdvAssert.ThrowsInvalidOperation(() => driver.GetRequest());
        }
Exemplo n.º 2
0
        public void ReplyRequest_ForStoppedOutside()
        {
            driver.Start();
            driverSC.SetStatus(ServiceControllerStatus.Stopped);

            AdvAssert.ThrowsInvalidOperation(() => driver.ReplyRequest(new ACCESS_REQUEST(), false));
        }
Exemplo n.º 3
0
        public void GetRequest_FilterGetMessageFails()
        {
            driver.Start();
            fltLib.SetGetMessageReturn(-125, new ACCESS_REQUEST());

            AdvAssert.Throws <COMException>(() => driver.GetRequest(), "ErrorCode", -125);
        }
Exemplo n.º 4
0
        public void GetRulesRow_UnknownProcessPath()
        {
            var ruleset = new Ruleset();
            var Rule    = AddRule(ruleset, @"c:\test.txt", @"c:\knownproc.exe");

            AdvAssert.ThrowsArgument(() => ruleset.GetRulesRow(Rule.PathID, @"c:\unknownn_process.exe"), "processPath");
        }
Exemplo n.º 5
0
        public void DetailsVisibile_WhenLogViewIsNull()
        {
            var presenter = new LogViewPresenter(new LogViewModel(eventLog));

            AdvAssert.ThrowsInvalidOperation(() => presenter.DetailsVisible.ToString());
            AdvAssert.ThrowsInvalidOperation(() => presenter.DetailsVisible = false);
        }
Exemplo n.º 6
0
        public void SendCommand_ToStartedOutside()
        {
            // Start outside
            driverSC.SetStatus(ServiceControllerStatus.Running);

            AdvAssert.ThrowsInvalidOperation(() => driver.SendCommand(COMMAND_TYPE.ADD, @"C:\SomeFolder\somefile.txt", 0));
        }
Exemplo n.º 7
0
        public void GetRulesRow_UnknownPathID()
        {
            var ruleset = new Ruleset();

            AddRule(ruleset, @"c:\test.txt", @"c:\knownproc.exe");

            AdvAssert.ThrowsArgument(() => ruleset.GetRulesRow(333, @"c:\knownproc.exe"), "pathID");
        }
Exemplo n.º 8
0
        public void Stop_CloseHandleFails()
        {
            driver.Start();

            fltLib.CloseHandleReturn = false;

            AdvAssert.ThrowsInvalidOperation(() => driver.Stop());
        }
Exemplo n.º 9
0
        public void FilterReplyMessage_IncorrectAllow()
        {
            var incorrectAllow = new PERMISSION {
                Allow = 12321, MessageId = 22
            };

            AdvAssert.ThrowsArgumentOutOfRange(() => stub.FilterReplyMessage(IntPtr.Zero, ref incorrectAllow, 0), "lpReplyBuffer", null);
        }
Exemplo n.º 10
0
        public void SendCommand_AddingSamePaths()
        {
            driver.Start();

            driver.SendCommand(COMMAND_TYPE.ADD, "C:\\test.txt", 1);

            AdvAssert.Throws <PathAlreadyAddedException>(() => driver.SendCommand(COMMAND_TYPE.ADD, "C:\\test.txt", 1),
                                                         "Path", "C:\\test.txt");
        }
Exemplo n.º 11
0
        public void ReplyRequest_FilterReplyMessageFails()
        {
            driver.Start();
            fltLib.FilterReplyMessageReturnCode = -125;

            AdvAssert.Throws <COMException>(() => driver.ReplyRequest(new ACCESS_REQUEST {
                MessageId = 1
            }, true), "ErrorCode", -125);
        }
Exemplo n.º 12
0
        public void ShowEventsClicked_Redirected()
        {
            var mainView  = new MainViewStub();
            var presenter = new MainViewPresenter(new ServiceGateway(new AdvSCStub(), new ServiceInterfaceManagerStub()))
            {
                MainView = mainView
            };

            AdvAssert.Raises <EventArgs>(() => mainView.ShowEvents(), presenter, "ShowEventsClicked");
        }
Exemplo n.º 13
0
        public void Start_ConnectFails()
        {
            // Start will throw COMException in case if FilterConnectCommunication fail.

            // FilterConnectCommunicationPort will return this error code.
            fltLib.FilterConnectCommunicationPortReturnCode = -123;

            // Act - Assert
            AdvAssert.Throws <COMException>(() => driver.Start(), "ErrorCode", -123);
        }
Exemplo n.º 14
0
        public void Deserialize_WrongData()
        {
            var wrongData = new byte[450];

            for (var i = 0; i < 450; i++)
            {
                wrongData[i] = (byte)i;
            }

            AdvAssert.ThrowsArgument(() => LogEntryData.Deserialize(new byte[] {}), "data");
        }
Exemplo n.º 15
0
        public void TestEventInvokators()
        {
            var stub = new FormMainStub();

            AdvAssert.Raises <EventArgs>(() => stub.ShowMain(), stub, "ShowMainClicked");
            AdvAssert.Raises <EventArgs>(() => stub.ShowRules(), stub, "ShowRulesClicked");
            AdvAssert.Raises <EventArgs>(() => stub.ShowPreferences(), stub, "ShowPreferencesClicked");
            AdvAssert.Raises <EventArgs>(() => stub.ShowEvents(), stub, "ShowEventsClicked");
            AdvAssert.Raises <EventArgs>(() => stub.CloseAll(), stub, "CloseAllClicked");
            AdvAssert.Raises <EventArgs>(() => stub.RefreshRules(), stub, "RefreshRulesClicked");
            AdvAssert.Raises <EventArgs>(() => stub.RefreshEvents(), stub, "RefreshEventsClicked");
            AdvAssert.Raises <EventArgs>(() => stub.ExitAndShutDown(), stub, "ExitAndShutDownClicked");
            AdvAssert.Raises <EventArgs>(() => stub.ClearEvents(), stub, "ClearEventsClicked");
            AdvAssert.Raises <EventArgs>(() => stub.ShowEventDetails(), stub, "ShowEventDetailsClicked");
            AdvAssert.Raises <ExportEventsEventArgs>(() => stub.ExportEvents(), stub, "ExportEventsClicked");
            AdvAssert.Raises <EventArgs>(() => stub.AutoRefreshEventsSetCheck(true), stub, "AutoRefreshEventsCheckChanged");
            Assert.IsTrue(stub.AutoRefreshEvents);
        }
Exemplo n.º 16
0
        public void Start_IntermediateStatusesArentSupported()
        {
            // Assert
            var UnsupportedStatuses = new[]
            {
                ServiceControllerStatus.ContinuePending,
                ServiceControllerStatus.Paused,
                ServiceControllerStatus.PausePending,
                ServiceControllerStatus.StartPending,
                ServiceControllerStatus.StopPending
            };

            // Act - Assert
            foreach (var unsupportedStatus in UnsupportedStatuses)
            {
                driverSC.SetStatus(unsupportedStatus);
                AdvAssert.Throws <NotSupportedException>(() => driver.Start());
            }
        }
Exemplo n.º 17
0
        public void Paths_ExpandedPath_NotSupportedRegistryPaths()
        {
            var rs      = new Ruleset();
            var PathRow = rs.Paths.AddPathsRow("123");

            var TestValues = new[]
            {
                @"HKEY_CURRENT_CONFIG\Software",
                @"HKCC\Software",
                @"HKEY_CLASSES_ROOT\._sln",
                @"HKCR\._sln",
                @"HKEY_DYN_DATA\123",
                @"HKDD\123",
                @"HKEY_PERFORMANCE_DATA\123",
                @"HKPD\123"
            };

            foreach (var testValue in TestValues)
            {
                PathRow.Path = testValue;
                AdvAssert.ThrowsInvalidOperation(delegate { var p = PathRow.ExpandedPaths; });
            }
        }
Exemplo n.º 18
0
 public void Constructor_NullEventLog()
 {
     AdvAssert.ThrowsArgumentNull(() => new LogViewPresenter(null), "logViewModel");
 }
Exemplo n.º 19
0
 public void SendCommand_DelEmptyPath()
 {
     driver.Start();
     AdvAssert.ThrowsArgument(() => driver.SendCommand(COMMAND_TYPE.DEL, string.Empty, 0), "path");
 }
Exemplo n.º 20
0
 public void Constructor_Null()
 {
     AdvAssert.ThrowsArgumentNull(() => new AdvSC(null), "serviceName");
 }
Exemplo n.º 21
0
        public void Start_AlreadyStarted()
        {
            driver.Start();

            AdvAssert.ThrowsInvalidOperation(driver.Start);
        }
Exemplo n.º 22
0
 public void ReplyRequest_ToStopped()
 {
     AdvAssert.ThrowsInvalidOperation(() => driver.ReplyRequest(new ACCESS_REQUEST(), false));
 }
Exemplo n.º 23
0
 public void Deserialize_EmptyArray()
 {
     AdvAssert.ThrowsArgument(() => LogEntryData.Deserialize(new byte[] {}), "data");
 }
Exemplo n.º 24
0
        public void SendCommand_AddNullPath()
        {
            driver.Start();

            AdvAssert.ThrowsArgument(() => driver.SendCommand(COMMAND_TYPE.ADD, null, 0), "path");
        }
Exemplo n.º 25
0
 public void Deserialize_Null()
 {
     AdvAssert.ThrowsArgumentNull(() => LogEntryData.Deserialize(null), "data");
 }
Exemplo n.º 26
0
 public void GetRequest_FromStopped()
 {
     AdvAssert.ThrowsInvalidOperation(() => driver.GetRequest());
 }
Exemplo n.º 27
0
 public void SendCommand_FilterSendMessageFails()
 {
     fltLib.FilterSendMessageReturnCode = -123;
     driver.Start();
     AdvAssert.Throws <COMException>(() => driver.SendCommand(COMMAND_TYPE.ADD, @"C:\somefile.txt", 22), "ErrorCode", -123);
 }
Exemplo n.º 28
0
 public void SendCommand_DelValidPath()
 {
     driver.Start();
     AdvAssert.ThrowsArgument(() => driver.SendCommand(COMMAND_TYPE.DEL, "C:\\test.txt", 0), "path");
 }
Exemplo n.º 29
0
 public void SendCommand_ToStopped()
 {
     AdvAssert.ThrowsInvalidOperation(() => driver.SendCommand(COMMAND_TYPE.ADD, @"C:\SomeFolder\somefile.txt", 0));
 }
Exemplo n.º 30
0
        public void SendCommand_DelNotAddedID()
        {
            driver.Start();

            AdvAssert.Throws <IdNotFoundException>(() => driver.SendCommand(COMMAND_TYPE.DEL, null, 33), "ID", 33);
        }