public void FindModuleIdTriesAllProviders() { //Arrange var request = new HttpRequestMessage(); var configuration = new HttpConfiguration(); var provider = new Mock<ITabAndModuleInfoProvider>(); int i; provider.Setup(x => x.TryFindModuleId(request, out i)).Returns(false); configuration.AddTabAndModuleInfoProvider(provider.Object); configuration.AddTabAndModuleInfoProvider(provider.Object); request.Properties[HttpPropertyKeys.HttpConfigurationKey] = configuration; //Act request.FindModuleId(); //Assert provider.Verify(x => x.TryFindModuleId(request, out i), Times.Exactly(2)); }
private static void ValidateTabAndModuleContext(HttpRequestMessage request, int portalId, out int tabId) { tabId = request.FindTabId(); if (tabId != Null.NullInteger) { if (!TabIsInPortal(tabId, portalId)) { throw new HttpResponseException(request.CreateErrorResponse(HttpStatusCode.BadRequest, Localization.GetString("TabNotInPortal", Localization.ExceptionsResourceFile))); } int moduleId = request.FindModuleId(); if (moduleId != Null.NullInteger) { var module = ModuleController.Instance.GetModule(moduleId, tabId, false); if (module == null) { throw new HttpResponseException(request.CreateErrorResponse(HttpStatusCode.BadRequest, Localization.GetString("TabModuleNotExist", Localization.ExceptionsResourceFile))); } } } }
public void FindModuleIdStopCallingProvidersAfterOneSuccess() { //Arrange var request = new HttpRequestMessage(); var configuration = new HttpConfiguration(); var provider = new Mock<ITabAndModuleInfoProvider>(); int i; provider.Setup(x => x.TryFindModuleId(request, out i)).Returns(true); configuration.AddTabAndModuleInfoProvider(provider.Object); configuration.AddTabAndModuleInfoProvider(provider.Object); request.Properties[HttpPropertyKeys.HttpConfigurationKey] = configuration; //Act request.FindModuleId(); //Assert provider.Verify(x => x.TryFindModuleId(request, out i), Times.Once()); }