示例#1
0
        public void RemoveCompanyRoleState_Succeeds()
        {
            var          companyGuid             = Guid.NewGuid();
            const string companyName             = "Cool Company";
            var          roleGuid                = Guid.NewGuid();
            const string roleName                = "Software Developer 2";
            var          inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder();
            var          options = inMemoryDatabaseBuilder
                                   .WithCompanyState(companyGuid, companyName)
                                   .WithCompanyRoleState(roleGuid, roleName, companyGuid)
                                   .Build("GetCompanyState", 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);
                sut.RemoveRoleFromCompanyState(companyGuid, roleGuid);
                var companyState = sut.GetCompanyState(companyGuid);
                var roleState    = companyState.CompanyRoleStates.SingleOrDefault(w => w.Guid == roleGuid);
                roleState = context.CompanyRoleStates.Find(roleGuid);
                Assert.Equal(EntityState.Deleted, context.Entry(roleState).State);
                Assert.Equal(roleName, roleState.Name);
            }
        }
        public void RemoveProjectRoleState_Succeeds()
        {
            var          projectGuid             = Guid.NewGuid();
            const string projectName             = "Cool Project";
            var          roleGuid                = Guid.NewGuid();
            const string roleName                = "Tester";
            var          inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder();
            var          options = inMemoryDatabaseBuilder
                                   .WithProjectState(projectGuid, projectName)
                                   .WithProjectRoleState(roleGuid, roleName, projectGuid)
                                   .Build("GetProjectState", 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);
                sut.RemoveRoleFromProjectState(projectGuid, roleGuid);
                var projectState = sut.GetProjectState(projectGuid);
                var roleState    = projectState.ProjectRoleStates.SingleOrDefault(w => w.Guid == roleGuid);
                //Assert.Null(roleState); inconsistent testbehavior vs CompanyRole
                roleState = context.ProjectRoleStates.Find(roleGuid);
                Assert.Equal(EntityState.Deleted, context.Entry(roleState).State);
                Assert.Equal(roleName, roleState.Name);
            }
        }
示例#3
0
        public void CanDeleteCompanyState()
        {
            var guid = Guid.NewGuid();
            var name = "To be deleted.";
            var inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder();
            var options = inMemoryDatabaseBuilder.WithCompanyState(guid, name).Build("DeleteCompanyState", 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.CompanyStates.Find(guid);
                Assert.Equal(EntityState.Unchanged, context.Entry(state).State);

                sut.DeleteCompanyState(guid);

                Assert.Equal(EntityState.Deleted, context.Entry(state).State);
            }
        }
示例#4
0
        public void GetCompanyState_Succeeds_OnlyWhenGuidMatchesExisting()
        {
            var          guid                    = Guid.NewGuid();
            var          invalidGuid             = Guid.NewGuid();
            const string name                    = "Cool Company";
            var          inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder();
            var          options                 = inMemoryDatabaseBuilder.WithCompanyState(guid, name).Build("GetCompanyState");

            // 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.GetCompanyState(guid);
                var invalidState = sut.GetCompanyState(invalidGuid);

                Assert.Equal(name, state.Name);

                Assert.Null(invalidState);
            }
        }
示例#5
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);
            }
        }
示例#6
0
        public void AddCompanyRoleState_Succeeds_WithNewRole_AndCreatesRoleState()
        {
            var          companyGuid             = Guid.NewGuid();
            const string companyName             = "Cool Company";
            var          roleGuid                = Guid.NewGuid();
            const string roleName                = "Tester";
            var          inMemoryDatabaseBuilder = new InMemoryDatabaseBuilder();
            var          options = inMemoryDatabaseBuilder
                                   .WithCompanyState(companyGuid, companyName)
                                   .Build("GetCompanyState", 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);
                sut.AddRoleToCompanyState(companyGuid, roleGuid, roleName);
                var companyState = sut.GetCompanyState(companyGuid);
                var roleState    = companyState.CompanyRoleStates.Single(w => w.Guid == roleGuid);

                Assert.Equal(EntityState.Added, context.Entry(roleState).State);
                Assert.Equal(roleName, roleState.Name);
            }
        }