public void GetRequest_ForStoppedOutside() { driver.Start(); driverSC.SetStatus(ServiceControllerStatus.Stopped); AdvAssert.ThrowsInvalidOperation(() => driver.GetRequest()); }
public void ReplyRequest_ForStoppedOutside() { driver.Start(); driverSC.SetStatus(ServiceControllerStatus.Stopped); AdvAssert.ThrowsInvalidOperation(() => driver.ReplyRequest(new ACCESS_REQUEST(), false)); }
public void GetRequest_FilterGetMessageFails() { driver.Start(); fltLib.SetGetMessageReturn(-125, new ACCESS_REQUEST()); AdvAssert.Throws <COMException>(() => driver.GetRequest(), "ErrorCode", -125); }
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"); }
public void DetailsVisibile_WhenLogViewIsNull() { var presenter = new LogViewPresenter(new LogViewModel(eventLog)); AdvAssert.ThrowsInvalidOperation(() => presenter.DetailsVisible.ToString()); AdvAssert.ThrowsInvalidOperation(() => presenter.DetailsVisible = false); }
public void SendCommand_ToStartedOutside() { // Start outside driverSC.SetStatus(ServiceControllerStatus.Running); AdvAssert.ThrowsInvalidOperation(() => driver.SendCommand(COMMAND_TYPE.ADD, @"C:\SomeFolder\somefile.txt", 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"); }
public void Stop_CloseHandleFails() { driver.Start(); fltLib.CloseHandleReturn = false; AdvAssert.ThrowsInvalidOperation(() => driver.Stop()); }
public void FilterReplyMessage_IncorrectAllow() { var incorrectAllow = new PERMISSION { Allow = 12321, MessageId = 22 }; AdvAssert.ThrowsArgumentOutOfRange(() => stub.FilterReplyMessage(IntPtr.Zero, ref incorrectAllow, 0), "lpReplyBuffer", null); }
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"); }
public void ReplyRequest_FilterReplyMessageFails() { driver.Start(); fltLib.FilterReplyMessageReturnCode = -125; AdvAssert.Throws <COMException>(() => driver.ReplyRequest(new ACCESS_REQUEST { MessageId = 1 }, true), "ErrorCode", -125); }
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"); }
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); }
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"); }
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); }
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()); } }
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; }); } }
public void Constructor_NullEventLog() { AdvAssert.ThrowsArgumentNull(() => new LogViewPresenter(null), "logViewModel"); }
public void SendCommand_DelEmptyPath() { driver.Start(); AdvAssert.ThrowsArgument(() => driver.SendCommand(COMMAND_TYPE.DEL, string.Empty, 0), "path"); }
public void Constructor_Null() { AdvAssert.ThrowsArgumentNull(() => new AdvSC(null), "serviceName"); }
public void Start_AlreadyStarted() { driver.Start(); AdvAssert.ThrowsInvalidOperation(driver.Start); }
public void ReplyRequest_ToStopped() { AdvAssert.ThrowsInvalidOperation(() => driver.ReplyRequest(new ACCESS_REQUEST(), false)); }
public void Deserialize_EmptyArray() { AdvAssert.ThrowsArgument(() => LogEntryData.Deserialize(new byte[] {}), "data"); }
public void SendCommand_AddNullPath() { driver.Start(); AdvAssert.ThrowsArgument(() => driver.SendCommand(COMMAND_TYPE.ADD, null, 0), "path"); }
public void Deserialize_Null() { AdvAssert.ThrowsArgumentNull(() => LogEntryData.Deserialize(null), "data"); }
public void GetRequest_FromStopped() { AdvAssert.ThrowsInvalidOperation(() => driver.GetRequest()); }
public void SendCommand_FilterSendMessageFails() { fltLib.FilterSendMessageReturnCode = -123; driver.Start(); AdvAssert.Throws <COMException>(() => driver.SendCommand(COMMAND_TYPE.ADD, @"C:\somefile.txt", 22), "ErrorCode", -123); }
public void SendCommand_DelValidPath() { driver.Start(); AdvAssert.ThrowsArgument(() => driver.SendCommand(COMMAND_TYPE.DEL, "C:\\test.txt", 0), "path"); }
public void SendCommand_ToStopped() { AdvAssert.ThrowsInvalidOperation(() => driver.SendCommand(COMMAND_TYPE.ADD, @"C:\SomeFolder\somefile.txt", 0)); }
public void SendCommand_DelNotAddedID() { driver.Start(); AdvAssert.Throws <IdNotFoundException>(() => driver.SendCommand(COMMAND_TYPE.DEL, null, 33), "ID", 33); }