public void ProcessDependentOpResults_SucceedsOnNoErrorMessage() { var remoteHashLoc = new ResourceLocationBase("RemoteHash", "Remote", kRemoteHashProviderId, typeof(string)); var localHashLoc = new ResourceLocationBase("LocalHash", "Local", kLocalHashProviderId, typeof(string)); var catalogLoc = new ResourceLocationBase("cat", "cat_id", nameof(TestCatalogProvider), typeof(IResourceLocator), remoteHashLoc, localHashLoc); var op1 = new ExceptionTestOperation(null, "good result", true); var handle1 = new AsyncOperationHandle(op1); var results = new List <AsyncOperationHandle>(); var loc = new TestLocator(kLocatorId); var locInfo = new AddressablesImpl.ResourceLocatorInfo(loc, "same", catalogLoc); var locInfos = new List <AddressablesImpl.ResourceLocatorInfo>(); locInfos.Add(locInfo); var trivialHashes = new List <string>(new[] { "same" }); results.Add(handle1); bool success; string errorString; var result = CheckCatalogsOperation.ProcessDependentOpResults(results, locInfos, trivialHashes, out errorString, out success); Assert.AreEqual(true, success, "Operation should succeed when underlying operation op1 has a null OperationException"); Assert.IsNull(errorString, "Error string should be null when operation is succeeding without errors."); Assert.NotNull(result, "Result should only be null when every operation within it fails."); }
public void ProcessDependentOpResults_FailsWithErrorMessageOnInternalError() { var remoteHashLoc = new ResourceLocationBase("RemoteHash", "Remote", kRemoteHashProviderId, typeof(string)); var localHashLoc = new ResourceLocationBase("LocalHash", "Local", kLocalHashProviderId, typeof(string)); var catalogLoc = new ResourceLocationBase("cat", "cat_id", nameof(TestCatalogProvider), typeof(IResourceLocator), remoteHashLoc, localHashLoc); var op1 = new ExceptionTestOperation(new Exception("Bad operation"), null); var handle1 = new AsyncOperationHandle(op1); var results = new List <AsyncOperationHandle>(); var loc = new TestLocator(kLocatorId); var locInfo = new AddressablesImpl.ResourceLocatorInfo(loc, "same", catalogLoc); var locInfos = new List <AddressablesImpl.ResourceLocatorInfo>(); locInfos.Add(locInfo); var trivialHashes = new List <string>(new[] { "badHash" }); results.Add(handle1); bool success; string errorString; var result = CheckCatalogsOperation.ProcessDependentOpResults(results, locInfos, trivialHashes, out errorString, out success); LogAssert.Expect(LogType.Error, "System.Exception: Bad operation"); Assert.AreEqual(false, success, "Operation should not succeed when underlying operation op1 has a non null OperationException"); Assert.AreEqual(true, errorString.Contains("Bad operation"), "Error string should contain the error message thrown by the underlying operation"); Assert.IsNull(result, "Result should be null in the case where every operation within it failed."); }
public void Locate_throws_cannot_locate_exception_when_result_count_is_different_than_given_id_count() { var testing = new TestLocator(true); var testingInterface = testing as ILocator; Assert.Throws <CannotLocateException>(() => testingInterface.Locate(type.of <string>(), new List <string> { "dummy" })); }
public List <TestOccurrences> All(TestLocator locator) { var result = new List <TestOccurrences>() { ByTestLocator(locator) }; while (!(string.IsNullOrEmpty(result.Last().NextHref))) { var response = m_caller.Get <TestOccurrences>(result.Last().NextHref, false); result.Add(response); } return(result); }
public void Locate_throws_cannot_locate_exception_when_result_is_null_and_locator_does_not_accept_null() { var testing = new TestLocator(false); var testingInterface = (ILocator)testing; testing.AcceptNullResult(true); var actual = testingInterface.Locate(type.of <string>(), new List <string> { "dummy" }); Assert.IsNull(actual[0]); testing.AcceptNullResult(false); Assert.Throws <CannotLocateException>(() => testingInterface.Locate(type.of <string>(), new List <string> { "dummy" })); }
protected override void Initialize() { base.Initialize(); SetupLogging(); var componentModel = (IComponentModel)GetService(typeof(SComponentModel)); var packageInstaller = componentModel.GetService <IVsPackageInstaller>(); var dte = (DTE2)GetService(typeof(DTE)); var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); LoadOptions(); _projectModel = new ProjectModel(dte); _tabJumper = new TabJumper(dte); _solutionHelper = new TestLocator(dte, uiShell, packageInstaller, _projectModel); var menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null == menuCommandService) { return; } var cmdIdJumpRight = new CommandID(GuidList.guidTddHelperCmdSet, (int)PkgCmdIDList.cmdIdJumpRight); var menuItemJumpRight = new MenuCommand(_tabJumper.JumpRight, cmdIdJumpRight); menuCommandService.AddCommand(menuItemJumpRight); var cmdIdJumpLeft = new CommandID(GuidList.guidTddHelperCmdSet, (int)PkgCmdIDList.cmdIdJumpLeft); var menuItemJumpLeft = new MenuCommand(_tabJumper.JumpLeft, cmdIdJumpLeft); menuCommandService.AddCommand(menuItemJumpLeft); var cmdIdLocateTest = new CommandID(GuidList.guidTddHelperCmdSet, (int)PkgCmdIDList.cmdIdLocateTest); var menuItemLocateTest = new MenuCommand(_solutionHelper.OpenTestOrImplementation, cmdIdLocateTest); menuCommandService.AddCommand(menuItemLocateTest); }
public void ProcessDependentOpResults_ReturnsFailureOnOneErrorMessage() { var remoteHashLoc = new ResourceLocationBase("RemoteHash", "Remote", kRemoteHashProviderId, typeof(string)); var localHashLoc = new ResourceLocationBase("LocalHash", "Local", kLocalHashProviderId, typeof(string)); var catalogLoc = new ResourceLocationBase("cat", "cat_id", nameof(TestCatalogProvider), typeof(IResourceLocator), remoteHashLoc, localHashLoc); var op1 = new ExceptionTestOperation(null, "good result", true); var op2 = new ExceptionTestOperation(new Exception("Bad operation"), null); var handle1 = new AsyncOperationHandle(op1); var handle2 = new AsyncOperationHandle(op2); var results = new List <AsyncOperationHandle>(); results.Add(handle1); results.Add(handle2); var loc = new TestLocator(kLocatorId); var locInfo1 = new AddressablesImpl.ResourceLocatorInfo(loc, "same", catalogLoc); var locInfo2 = new AddressablesImpl.ResourceLocatorInfo(loc, "bad", catalogLoc); var locInfos = new List <AddressablesImpl.ResourceLocatorInfo>(); locInfos.Add(locInfo1); locInfos.Add(locInfo2); var trivialHashes = new List <string>(new[] { "same", "good" }); bool success; string errorString; var result = CheckCatalogsOperation.ProcessDependentOpResults(results, locInfos, trivialHashes, out errorString, out success); LogAssert.Expect(LogType.Error, "System.Exception: Bad operation"); Assert.AreEqual(false, success, "Operation should fail when underlying operation op1 has a null OperationException, even if op2 has a non null OperationException"); Assert.AreEqual(true, errorString.Contains("Bad operation"), "Error string should contain the error message thrown by the underlying operation"); Assert.NotNull(result, "Result should only be null if every underlying operation fails."); Assert.NotNull(result[0], "Only failed operations should be null in the result list."); Assert.IsNull(result[1], "Failed operations should be null in the result list."); }
public TestOccurrences ByTestLocator(TestLocator locator) { return(m_caller.Get <TestOccurrences>($"/testOccurrences?locator=test:({locator})")); }
public List <TestOccurrences> All(TestLocator locator) { return(AllResults(ByTestLocator(locator))); }
public void it_returns_all_test_occurrences_for_test() { var result = m_client.Tests.All(TestLocator.WithId(m_goodTestId)); Assert.IsNotEmpty(result); }