コード例 #1
0
        public void CannotSaveAnEditToASession_WhenTheSessionBelongsToAnotherUser()
        {
            var session = new Session { SessionId = 1, SpeakerUserName = "******" };
            var controller = new SessionControllerBuilder().Updating(session).Build();

            var result = controller.Edit("fred", session);

            Assert.That(result, Is.InstanceOf<HttpUnauthorizedResult>());
        }
コード例 #2
0
        public void ShouldEmailTheUserTheirUpdatedSubmission_WhenEditing()
        {
            var postman = Substitute.For<IPostman>();
            var bob = new UserProfile { Name = "Bob", EmailAddress = "*****@*****.**", UserName = "******" };
            var session = new Session
            {
                Title = "Bob's even more awesome session",
                Abstract = "Just wait until you see it!",
                SpeakerUserName = bob.UserName,
                SessionId = 1
            };

            var controller = new SessionControllerBuilder()
                .WithPostman(postman)
                .ForUser(bob)
                .Updating(session)
                .Build();

            controller.Edit(bob.UserName, session);

            var expectedMailMessage = MailMessage.FromTemplate(SessionUpdatedMailTemplate.Create(session), bob);
            postman.Received().Deliver(expectedMailMessage);
        }