Ejemplo n.º 1
0
            public void WillGetTheCurrentUserUsingTheRequestIdentityName()
            {
                var controller = new TestableUsersController();

                controller.StubIdentity.Setup(stub => stub.Name).Returns("theUsername");

                controller.Account();

                controller.StubUserByUsernameQry.Verify(stub => stub.Execute("theUsername", true));
            }
Ejemplo n.º 2
0
            public void WillReturnTheAccountViewModelWithTheUserApiKey()
            {
                var stubApiKey = Guid.NewGuid();
                var controller = new TestableUsersController();
                controller.MockUserService
                          .Setup(s => s.FindByUsername(It.IsAny<string>()))
                          .Returns(new User { Key = 42, ApiKey = stubApiKey });
                
                // act
                var model = ((ViewResult)controller.Account()).Model as AccountViewModel;

                // verify
                Assert.Equal(stubApiKey.ToString(), model.ApiKey);
            }
Ejemplo n.º 3
0
            public void WillGetCuratedFeedsManagedByTheCurrentUser()
            {
                var controller = new TestableUsersController();
                controller.MockUserService
                          .Setup(s => s.FindByUsername(It.IsAny<string>()))
                          .Returns(new User { Key = 42 });
                
                // act
                controller.Account();

                // verify
                controller.MockCuratedFeedService
                          .Verify(query => query.GetFeedsForManager(42));
            }
Ejemplo n.º 4
0
            public void WillReturnTheAccountViewModelWithTheCuratedFeeds()
            {
                var controller = new TestableUsersController();

                controller.StubCuratedFeedsByManagerQry
                .Setup(stub => stub.Execute(It.IsAny <int>()))
                .Returns(new[] { new CuratedFeed {
                                     Name = "theCuratedFeed"
                                 } });

                var model = ((ViewResult)controller.Account()).Model as AccountViewModel;

                Assert.Equal("theCuratedFeed", model.CuratedFeeds.First());
            }
Ejemplo n.º 5
0
            public void WillGetCuratedFeedsManagedByTheCurrentUser()
            {
                var controller = new TestableUsersController();

                controller.StubUserByUsernameQry
                .Setup(stub => stub.Execute(It.IsAny <string>(), It.IsAny <bool>()))
                .Returns(new User {
                    Key = 42
                });

                controller.Account();

                controller.StubCuratedFeedsByManagerQry.Verify(stub => stub.Execute(42));
            }
Ejemplo n.º 6
0
            public void WillReturnTheAccountViewModelWithTheUserApiKey()
            {
                var controller = new TestableUsersController();
                var stubApiKey = Guid.NewGuid();

                controller.StubUserByUsernameQry
                .Setup(stub => stub.Execute(It.IsAny <string>(), It.IsAny <bool>()))
                .Returns(new User {
                    Key = 42, ApiKey = stubApiKey
                });

                var model = ((ViewResult)controller.Account()).Model as AccountViewModel;

                Assert.Equal(stubApiKey.ToString(), model.ApiKey);
            }
Ejemplo n.º 7
0
            public void WillReturnTheAccountViewModelWithTheCuratedFeeds()
            {
                var controller = new TestableUsersController();
                controller.MockUserService
                          .Setup(s => s.FindByUsername(It.IsAny<string>()))
                          .Returns(new User { Key = 42 });
                controller.MockCuratedFeedService
                          .Setup(stub => stub.GetFeedsForManager(It.IsAny<int>()))
                          .Returns(new[] { new CuratedFeed { Name = "theCuratedFeed" } });
                
                // act
                var model = ((ViewResult)controller.Account()).Model as AccountViewModel;

                // verify
                Assert.Equal("theCuratedFeed", model.CuratedFeeds.First());
            }
            public void WillReturnTheAccountViewModelWithTheUserApiKey()
            {
                var stubApiKey = Guid.NewGuid();
                var controller = new TestableUsersController();

                controller.MockUserService
                .Setup(s => s.FindByUsername(It.IsAny <string>()))
                .Returns(new User {
                    Key = 42, ApiKey = stubApiKey
                });

                // act
                var model = ((ViewResult)controller.Account()).Model as AccountViewModel;

                // verify
                Assert.Equal(stubApiKey.ToString(), model.ApiKey);
            }
            public void WillGetCuratedFeedsManagedByTheCurrentUser()
            {
                var controller = new TestableUsersController();

                controller.MockUserService
                .Setup(s => s.FindByUsername(It.IsAny <string>()))
                .Returns(new User {
                    Key = 42
                });

                // act
                controller.Account();

                // verify
                controller.MockFeedsQuery
                .Verify(query => query.Execute(42));
            }
Ejemplo n.º 10
0
            public void WillGetTheCurrentUserUsingTheRequestIdentityName()
            {
                var controller = new TestableUsersController();
                controller.MockCurrentIdentity
                          .Setup(stub => stub.Name)
                          .Returns("theUsername");
                controller.MockUserService
                          .Setup(s => s.FindByUsername(It.IsAny<string>()))
                          .Returns(new User { Key = 42 });
                
                //act
                controller.Account();

                // verify
                controller.MockUserService
                          .Verify(stub => stub.FindByUsername("theUsername"));
            }
            public void WillGetTheCurrentUserUsingTheRequestIdentityName()
            {
                var controller = new TestableUsersController();

                controller.MockCurrentIdentity
                .Setup(stub => stub.Name)
                .Returns("theUsername");
                controller.MockUserService
                .Setup(s => s.FindByUsername(It.IsAny <string>()))
                .Returns(new User {
                    Key = 42
                });

                //act
                controller.Account();

                // verify
                controller.MockUserService
                .Verify(stub => stub.FindByUsername("theUsername"));
            }
            public void WillReturnTheAccountViewModelWithTheCuratedFeeds()
            {
                var controller = new TestableUsersController();

                controller.MockUserService
                .Setup(s => s.FindByUsername(It.IsAny <string>()))
                .Returns(new User {
                    Key = 42
                });
                controller.MockFeedsQuery
                .Setup(stub => stub.Execute(It.IsAny <int>()))
                .Returns(new[] { new CuratedFeed {
                                     Name = "theCuratedFeed"
                                 } });

                // act
                var model = ((ViewResult)controller.Account()).Model as AccountViewModel;

                // verify
                Assert.Equal("theCuratedFeed", model.CuratedFeeds.First());
            }