Exemplo n.º 1
0
        public void SendEmail()
        {
            var storage = new DatabaseUserStorage(this.tests.LmsService);
            var email = storage.SendEmail("*****@*****.**", "*****@*****.**", "Test Email", "Test Email");

            Assert.IsTrue(email);
        }
Exemplo n.º 2
0
        public void EnglishChangesIntoUkrainian()
        {
            //lets make fake httpcontext using reflection
            var httpRequest = new HttpRequest("", "http://mySomething/", "");
            var stringWriter = new StringWriter();
            var httpResponce = new HttpResponse(stringWriter);
            var httpContext = new HttpContext(httpRequest, httpResponce);

            var sessionContainer = new HttpSessionStateContainer("id", new SessionStateItemCollection(),
                                                                 new HttpStaticObjectsCollection(), 10, true,
                                                                 HttpCookieMode.AutoDetect,
                                                                 SessionStateMode.InProc, false);

            httpContext.Items["AspSession"] = typeof(HttpSessionState).GetConstructor(
                                                     BindingFlags.NonPublic | BindingFlags.Instance,
                                                     null, CallingConventions.Standard,
                                                     new[] { typeof(HttpSessionStateContainer) },
                                                     null)
                                                .Invoke(new object[] { sessionContainer });
            
            HttpContext.Current = httpContext;
            IWindsorContainer container = new WindsorContainer();
            InitializeWindsor(ref container);
            AccountController pc = null;
            try
            {
                pc = new AccountController(new DatabaseUserStorage(container.Resolve<ILmsService>()));
            }
            catch (Exception e)
            {
            }
            var context = new Mock<ControllerContext>();

            var session = new MockHttpSession();

            context.Setup(m => m.HttpContext.Session).Returns(session);

            DatabaseUserStorage storage = new DatabaseUserStorage(null);//returns null but we don't need it

            pc.ControllerContext = context.Object;
            ViewResult result = pc.ChangeCulture("uk-UA", "/") as ViewResult;
            Assert.AreEqual("uk-UA", pc.Session["Culture"].ToString());

        }