public void GivenItem_WhenAdd_ThenAddToContext()
        {
            var expected = new LoginEvent { Id = 1 };

            Target.Add(expected);

            MockDbSet.AssertWasCalled(m => m.Add(expected));
        }
        public void GivenIdRequestParameter_AndUserMatchesId_WhenInvokeFilterPredicate_ThenReturnTrue()
        {
            LoginEvent item = new LoginEvent { CreatingUserId = 1 };
            MockRequest.Expect(m => m["id"]).Return("1");
            Target = new AuditLoginClientDataTable(MockRequest);

            Assert.IsTrue(Target.FilterPredicate.Compile().Invoke(item));
        }
        public void GivenItem_WhenUpdate_ThenThrowException()
        {
            var item = new LoginEvent { Id = 1 };

            Target.ExpectException<NotSupportedException>(() => Target.Update(item));
        }
 public void Update(LoginEvent item)
 {
     ThrowNotSupported();
 }
 public void Remove(LoginEvent item)
 {
     ThrowNotSupported();
 }
 public void Add(LoginEvent item)
 {
     Context.LoginEvents.Add(item);
 }
        public void GivenUser_WhenAuditLogin_ThenEventAddedToRepository_AndRepositorySaved()
        {
            LoginEvent expected = new LoginEvent();
            MockUserAuditor.Expect(m => m.CreateLoginEvent(User.Identity.User)).Return(expected);

            Target.AuditLogin(User);

            Repositories.MockLoginEventRepository.AssertWasCalled(m => m.Add(expected));
            Repositories.MockRepositoryContainer.AssertWasCalled(m => m.Save());
        }
Esempio n. 8
0
        public void WhenConstruct_ThenCreateTimeSet()
        {
            LoginEvent actual = new LoginEvent();

            Assert.IsTrue(actual.CreateTime.WithinTimeSpanOf(TimeSpan.FromMilliseconds(20), DateTime.Now));
        }
        public void WhenConstruct_ThenCreateTimeSet()
        {
            LoginEvent actual = new LoginEvent();

            Assert.IsTrue(actual.CreateTime.WithinTimeSpanOf(TimeSpan.FromMilliseconds(20), DateTime.Now));
        }