コード例 #1
0
        public void HelloWorldPresenterSetsViewMessageForAuthenticatedUser()
        {
            // Arrange
            var view        = MockRepository.GenerateStub <IView <HelloWorldModel> >();
            var httpContext = MockRepository.GenerateMock <HttpContextBase>();
            var identity    = MockRepository.GenerateMock <IIdentity>();
            var user        = MockRepository.GenerateMock <IPrincipal>();

            httpContext.Stub(h => h.User).Return(user).Repeat.Twice();
            user.Stub(u => u.Identity).Return(identity).Repeat.Twice();
            identity.Stub(i => i.IsAuthenticated).Return(true);
            const string name = "Bob";

            identity.Stub(i => i.Name).Return(name);

            var presenter = new HelloWorldPresenter(view)
            {
                HttpContext = httpContext
            };

            // Act
            view.Raise(v => v.Load += null, view, new EventArgs());

            // Assert
            Assert.AreEqual(string.Format("Hello {0}!", name), view.Model.Message);
        }
コード例 #2
0
        public void HelloWorldPresenterSetsViewMessageForAuthenticatedUser()
        {
            // Arrange
            var view = MockRepository.GenerateStub<IView<HelloWorldModel>>();
            var httpContext = MockRepository.GenerateMock<HttpContextBase>();
            var identity = MockRepository.GenerateMock<IIdentity>();
            var user = MockRepository.GenerateMock<IPrincipal>();

            httpContext.Stub(h => h.User).Return(user).Repeat.Twice();
            user.Stub(u => u.Identity).Return(identity).Repeat.Twice();
            identity.Stub(i => i.IsAuthenticated).Return(true);
            const string name = "Bob";
            identity.Stub(i => i.Name).Return(name);

            var presenter = new HelloWorldPresenter(view)
            {
                HttpContext = httpContext
            };

            // Act
            view.Raise(v => v.Load += null, view, new EventArgs());

            // Assert
            Assert.AreEqual(string.Format("Hello {0}!", name), view.Model.Message);
        }
コード例 #3
0
        public HelloWorld()
        {
            InitializeComponent();

            //initialize the presenter and call a function from the presenter
            Persenter = new HelloWorldPresenter(this);
            LoadText(this, EventArgs.Empty);
        }
コード例 #4
0
        public void HelloWorldPresenterSetsViewMessageForAnonymousUser()
        {
            // Arrange
            var view        = MockRepository.GenerateStub <IView <HelloWorldModel> >();
            var httpContext = MockRepository.GenerateMock <HttpContextBase>();
            var identity    = MockRepository.GenerateMock <IIdentity>();
            var user        = MockRepository.GenerateMock <IPrincipal>();

            httpContext.Stub(h => h.User).Return(user);
            user.Stub(u => u.Identity).Return(identity);
            identity.Stub(i => i.IsAuthenticated).Return(false);

            var presenter = new HelloWorldPresenter(view)
            {
                HttpContext = httpContext
            };

            // Act
            view.Raise(v => v.Load += null, view, new EventArgs());

            // Assert
            Assert.AreEqual("Hello World!", view.Model.Message);
        }
コード例 #5
0
        public void HelloWorldPresenterSetsViewMessageForAnonymousUser()
        {
            // Arrange
            var view = MockRepository.GenerateStub<IView<HelloWorldModel>>();
            var httpContext = MockRepository.GenerateMock<HttpContextBase>();
            var identity = MockRepository.GenerateMock<IIdentity>();
            var user = MockRepository.GenerateMock<IPrincipal>();

            httpContext.Stub(h => h.User).Return(user);
            user.Stub(u => u.Identity).Return(identity);
            identity.Stub(i => i.IsAuthenticated).Return(false);

            var presenter = new HelloWorldPresenter(view)
            {
                HttpContext = httpContext
            };

            // Act
            view.Raise(v => v.Load += null, view, new EventArgs());

            // Assert
            Assert.AreEqual("Hello World!", view.Model.Message);
        }
コード例 #6
0
ファイル: Default.aspx.cs プロジェクト: pjsamuel3/BDDSkeleton
 protected void Page_Load(object sender, EventArgs e)
 {
     _presenter = new HelloWorldPresenter(this);
 }