public virtual void FromCookies(bool pHasCookie) { var cookies = (pHasCookie ? TOauthSession.CreateWorkingCookie() : new HttpCookieCollection()); var mockLogger = new Mock <IFabricLog>(MockBehavior.Strict); mockLogger.Setup(x => x.Info(It.IsAny <string>(), It.IsAny <string>())); vMockConfig.SetupGet(x => x.Logger).Returns(mockLogger.Object); IFabricSessionContainer sc = FabricSessionContainer.FromCookies(vMockClient.Object, cookies); if (pHasCookie) { Assert.NotNull(sc, "Container should be filled."); Assert.NotNull(sc.Person, "Container.Person should be filled."); Assert.AreEqual("sessId", sc.Person.SessionId, "Incorrect Person.SessionId."); } else { Assert.Null(sc, "Container should be null."); } }
public void SetUp() { vKey = "Test"; vApiPath = "http://testFabric.com/api"; vAppId = 1; vAppSecret = "MySecretCode"; vAppOauthRedir = "http://testdomain.com/oauth"; vSessContain = new FabricSessionContainer(); vRedirProv = (k => vAppOauthRedir); vContainProv = (k => vSessContain); }
public void SetUp() { vSessProvCounter = 0; vConfig = new FabricClientConfig("Test", "http://testFabric.com/api", 1, "MySecretCode", (k => "http://testdomain.com/oauth"), SessionContainerProvider); vAppSess = new AppSession(vConfig, null); vSessContain = new FabricSessionContainer(); vContext = new ClientContext(vConfig); vContext.AppSess = vAppSess; FabricClient.InitOnce(vConfig); }
public virtual void SetUp() { vSessContain = new FabricSessionContainer(); MockConfig = new Mock <IFabricClientConfig>(MockBehavior.Strict); MockConfig.SetupGet(x => x.Logger).Returns(new FabricLog()); MockConfig.SetupGet(x => x.ApiPath).Returns("my/api/path"); MockConfig.SetupGet(x => x.AppId).Returns(1234); MockConfig.SetupGet(x => x.AppSecret).Returns("myAppSecret"); MockConfig.Setup(x => x.GetOauthRedirectUri()).Returns("re/dir/ect/uri"); MockOauth = new Mock <IOauthService>(MockBehavior.Strict); OauthSess = NewOauthSess(MockConfig.Object, MockOauth.Object); }
public virtual void FromValues() { const string sessId = "sessId"; const string grant = "grant"; const string bearer = "bearer"; const string refresh = "refresh"; DateTime exp = DateTime.UtcNow.AddMinutes(30); IFabricSessionContainer sc = FabricSessionContainer.FromValues(vMockClient.Object, sessId, grant, bearer, refresh, exp); Assert.NotNull(sc, "Container should be filled."); Assert.NotNull(sc.Person, "Container.Person should be filled."); Assert.AreEqual(sessId, sc.Person.SessionId, "Incorrect Person.SessionId."); Assert.AreEqual(grant, sc.Person.GrantCode, "Incorrect Person.GrantCode."); Assert.AreEqual(bearer, sc.Person.BearerToken, "Incorrect Person.BearerToken."); Assert.AreEqual(refresh, sc.Person.RefreshToken, "Incorrect Person.RefreshToken."); Assert.AreEqual(exp, sc.Person.Expiration, "Incorrect Person.Expiration."); }
/*--------------------------------------------------------------------------------------------*/ public void RunTest(ParameterizedThreadStart pDelegate) { var mockPerA = new Mock <IFabricPersonSession>(MockBehavior.Strict); mockPerA.SetupGet(x => x.SessionId).Returns("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); var sessContainA = new FabricSessionContainer { Person = mockPerA.Object }; var mockPerB = new Mock <IFabricPersonSession>(MockBehavior.Strict); mockPerB.SetupGet(x => x.SessionId).Returns("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); var sessContainB = new FabricSessionContainer { Person = mockPerB.Object }; var threadA = new Thread(pDelegate); var threadB = new Thread(pDelegate); var testA = new ThreadTest(); var testB = new ThreadTest(); vSessContainMap.Add(threadA.ManagedThreadId, sessContainA); vSessContainMap.Add(threadB.ManagedThreadId, sessContainB); threadA.Start(testA); threadB.Start(testB); threadA.Join(); threadB.Join(); if (testA.Failure != null) { Assert.Fail("Thread A: " + testA.Failure); } if (testB.Failure != null) { Assert.Fail("Thread B: " + testB.Failure); } }
public void SetUp() { vSessContain = new FabricSessionContainer(); FabricClient.InitOnce(GetConfig()); }
/*--------------------------------------------------------------------------------------------*/ private static IFabricSessionContainer SessionContainerProv(string pConfigKey) { return(FabricSessionContainer.FromHttpContext(HttpContext.Current, pConfigKey)); }