Esempio n. 1
0
        public void AddCommandTest(bool isAdmin)
        {
            using (var modelContext = new TestModelContext()) {
                var userId = 100;
                var now    = DateTime.Now;
                var entity = new DivisionInfo {
                    DivisionID = 1
                };
                var securityContext = new TestSecurityContext(userId, isAdmin);
                var command         = new AddCommand <DivisionInfo> (modelContext, securityContext);

                command.Add(entity, now);

                var entityLoaded = modelContext
                                   .QueryWhere <DivisionInfo> (d => d.DivisionID == entity.DivisionID)
                                   .SingleOrDefault();

                Assert.Equal(isAdmin, null != entityLoaded);

                if (entityLoaded != null)
                {
                    Assert.Equal(now, entityLoaded.CreatedOnDate);
                    Assert.Equal(now, entityLoaded.LastModifiedOnDate);
                    Assert.Equal(userId, entityLoaded.CreatedByUserId);
                    Assert.Equal(userId, entityLoaded.LastModifiedByUserId);
                }
            }
        }
        public void DeleteCommandTest(bool isAdmin)
        {
            using (var modelContext = new TestModelContext()) {
                var entity = new DivisionInfo {
                    DivisionID = 1
                };
                modelContext.Add(entity);

                var securityContext = new TestSecurityContext(1, isAdmin);
                var command         = new DeleteCommand <DivisionInfo> (modelContext, securityContext);

                command.Delete(entity);

                Assert.Equal(isAdmin, null == modelContext
                             .QueryWhere <DivisionInfo> (d => d.DivisionID == entity.DivisionID)
                             .SingleOrDefault());
            }
        }