コード例 #1
0
        public void Can_Search_Subsystem_By_Id()
        {
            // Arrange
            Assert.NotNull(_author);
            var sys = new Subsystem
            {
                Name          = "Test Subsystem",
                DefaultAuthor = _author,
                Description   = "Default Subsystem",
                NoteCatalogs  = new List <NoteCatalog>
                {
                    new()
                    {
                        Name   = "Test Catalog1",
                        Schema = "Test Catalog1 Schema",
                        Render = new NoteRender
                        {
                            Name        = "Test Catalog1 Render",
                            Namespace   = "Hmm.Render",
                            Description = "This is description of test catalog1 render"
                        }
                    }
                }
            };
            var newSys = SubsystemRepository.Add(sys);

            // Act
            var savedSys = SubsystemRepository.GetEntities().FirstOrDefault(c => c.Id == newSys.Id);

            // Assert
            Assert.NotNull(savedSys);
            Assert.Equal(savedSys.Name, sys.Name);
            Assert.True(SubsystemRepository.ProcessMessage.Success);
        }
コード例 #2
0
        public void Can_Update_Subsystem()
        {
            // Arrange
            Assert.NotNull(_author);
            var sys = new Subsystem
            {
                Name          = "Test Subsystem",
                DefaultAuthor = _author,
                Description   = "Default Subsystem",
                NoteCatalogs  = new List <NoteCatalog>
                {
                    new()
                    {
                        Name   = "Test Catalog1",
                        Schema = "Test Catalog1 Schema",
                        Render = new NoteRender
                        {
                            Name        = "Test Catalog1 Render",
                            Namespace   = "Hmm.Render",
                            Description = "This is description of test catalog1 render"
                        }
                    },
                    new ()
                    {
                        Name   = "Test Catalog2",
                        Schema = "Test Catalog2 Schema",
                        Render = new NoteRender
                        {
                            Name        = "Test Catalog2 Render",
                            Namespace   = "Hmm.Render",
                            Description = "This is description of test catalog2 render"
                        }
                    }
                }
            };
            var newSys   = SubsystemRepository.Add(sys);
            var savedSys = LookupRepo.GetEntities <Subsystem>().FirstOrDefault(s => s.Id == newSys.Id);

            Assert.NotNull(savedSys);

            // Act
            savedSys.Description = "changed default Subsystem";
            var firstCatalog = savedSys.NoteCatalogs.First();

            Assert.NotNull(firstCatalog);
            firstCatalog.Name        = "Updated Test Catalog1";
            firstCatalog.Render.Name = "Update Test Catalog1 Render Name";
            var updatedSys = SubsystemRepository.Update(savedSys);

            // Assert
            Assert.NotNull(updatedSys);
            Assert.Equal("changed default Subsystem", updatedSys.Description);
            Assert.True(SubsystemRepository.ProcessMessage.Success);
        }
コード例 #3
0
        public void Dispose()
        {
            if (_dbContext is DbContext context)
            {
                context.Reset();
            }

            var systems = LookupRepo.GetEntities <Subsystem>().ToList();

            foreach (var sys in systems)
            {
                SubsystemRepository.Delete(sys);
            }
            var notes = LookupRepo.GetEntities <HmmNote>().ToList();

            foreach (var note in notes)
            {
                NoteRepository.Delete(note);
            }

            var catalogs = LookupRepo.GetEntities <NoteCatalog>().ToList();

            foreach (var catalog in catalogs)
            {
                CatalogRepository.Delete(catalog);
            }

            var renders = LookupRepo.GetEntities <NoteRender>().ToList();

            foreach (var render in renders)
            {
                RenderRepository.Delete(render);
            }

            var authors = LookupRepo.GetEntities <Author>().ToList();

            foreach (var author in authors)
            {
                AuthorRepository.Delete(author);
            }

            if (_dbContext is DbContext newContext)
            {
                newContext.Reset();
            }
            GC.SuppressFinalize(this);
        }
コード例 #4
0
        public void Can_Add_Subsystem_To_DataSource()
        {
            // Arrange
            Assert.NotNull(_author);
            var sys = new Subsystem
            {
                Name          = "Test subsystem",
                DefaultAuthor = _author,
                Description   = "Default subsystem",
                NoteCatalogs  = new List <NoteCatalog>
                {
                    new()
                    {
                        Name   = "Test Catalog1",
                        Schema = "Test Catalog1 Schema",
                        Render = new NoteRender
                        {
                            Name        = "Test Catalog1 Render",
                            Namespace   = "Hmm.Render",
                            Description = "This is description of test catalog1 render"
                        }
                    },
                    new ()
                    {
                        Name   = "Test Catalog2",
                        Schema = "Test Catalog2 Schema",
                        Render = new NoteRender
                        {
                            Name        = "Test Catalog2 Render",
                            Namespace   = "Hmm.Render",
                            Description = "This is description of test catalog2 render"
                        }
                    }
                }
            };

            // Act
            var newSys = SubsystemRepository.Add(sys);

            // Assert
            Assert.NotNull(newSys);
            Assert.Equal(2, newSys.NoteCatalogs.Count());
            Assert.True(newSys.Id > 0, "newSubsystem.Id >=1");
            Assert.Equal("Test subsystem", newSys.Name);
            Assert.True(SubsystemRepository.ProcessMessage.Success);
        }
コード例 #5
0
        protected void SetupRecords(
            IEnumerable <Author> authors,
            IEnumerable <NoteRender> renders,
            IEnumerable <NoteCatalog> catalogs,
            IEnumerable <Subsystem> subsystems)
        {
            Guard.Against <ArgumentNullException>(authors == null, nameof(authors));
            Guard.Against <ArgumentNullException>(renders == null, nameof(renders));
            Guard.Against <ArgumentNullException>(catalogs == null, nameof(catalogs));
            Guard.Against <ArgumentNullException>(subsystems == null, nameof(subsystems));

            // ReSharper disable PossibleNullReferenceException
            try
            {
                foreach (var user in authors)
                {
                    AuthorRepository.Add(user);
                }

                //foreach (var render in renders)
                //{
                //    RenderRepository.Add(render);
                //}

                //foreach (var catalog in catalogs)
                //{
                //    CatalogRepository.Add(catalog);
                //}

                foreach (var sys in subsystems)
                {
                    SubsystemRepository.Add(sys);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            // ReSharper restore PossibleNullReferenceException
        }