예제 #1
0
        public void CanDeleteEmploymentState()
        {
            var guid                    = Guid.NewGuid();
            var contactGuid             = Guid.NewGuid();
            var companyRoleGuid         = Guid.NewGuid();
            var inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder();
            var options                 = inMemoryDatabaseBuilder.WithEmploymentState(guid, contactGuid, companyRoleGuid).Build("DeleteEmploymentState", true);

            // Run the test against a clean instance of the context
            using (var context = new MainContext(options))
            {
                inMemoryDatabaseBuilder.InitializeContext(context);
                var sut   = new MainRepository(context);
                var state = context.EmploymentStates.Find(guid);
                Assert.Equal(EntityState.Unchanged, context.Entry(state).State);

                sut.DeleteEmploymentState(guid);

                Assert.Equal(EntityState.Deleted, context.Entry(state).State);
            }
        }
예제 #2
0
        public void GetEmploymentState_Succeeds_OnlyWhenGuidMatchesExisting()
        {
            var guid                    = Guid.NewGuid();
            var contactGuid             = Guid.NewGuid();
            var companyRoleGuid         = Guid.NewGuid();
            var invalidGuid             = Guid.NewGuid();
            var inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder();
            var options                 = inMemoryDatabaseBuilder.WithEmploymentState(guid, contactGuid, companyRoleGuid).Build("GetEmploymentState");

            // Run the test against a clean instance of the context
            using (var context = new MainContext(options))
            {
                inMemoryDatabaseBuilder.InitializeContext(context);
                var sut          = new MainRepository(context);
                var state        = sut.GetEmploymentState(guid);
                var invalidState = sut.GetEmploymentState(invalidGuid);

                Assert.Equal(contactGuid, state.ContactGuid);
                Assert.Equal(companyRoleGuid, state.CompanyRoleGuid);

                Assert.Null(invalidState);
            }
        }