Esempio n. 1
0
        public void DoesFindByNameWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                ITownDataService    townService = new TownDataService(dbContext);
                IAddressDataService service     = new AddressDataService(dbContext);

                CreateTownServiceModel createTownServiceModel = new CreateTownServiceModel()
                {
                    Name     = "Pernik",
                    PostCode = 2300
                };

                townService.Create(createTownServiceModel);

                CreateAddressServiceModel model = new CreateAddressServiceModel()
                {
                    AddressText = "new",
                    TownId      = 1
                };

                service.Create(model);

                var result = service.FindByName("new").AddressText;

                Assert.AreEqual(result, dbContext.Addresses.FirstOrDefault().AddressText);
            }
        }
        public void DoesIsValidCompanyWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                ICompanyDataService service = new CompanyDataSerive(dbContext);

                CreateCompanyServiceModel serviceModel = new CreateCompanyServiceModel
                {
                    Name        = "MDM",
                    Description = "No"
                };

                service.Create(serviceModel);

                var companyCode = service.FindByName("MDM").CompanyCode;

                var result = service.IsValidCompany(companyCode);

                Assert.IsTrue(result);
            }
        }
 public EmployeeDataService(MDManagementDbContext data,
                            IJobTitleDataService jobTitleDataService,
                            ICompanyDataService companyDataService,
                            UserManager <Employee> userManager)
 {
     this.data = data;
     this.jobTitleDataService = jobTitleDataService;
     this.companyDataService  = companyDataService;
     this.userManager         = userManager;
 }
Esempio n. 4
0
 public HomeController(ILogger <HomeController> logger,
                       UserManager <Employee> userManager,
                       MDManagementDbContext data,
                       ICompanyDataService companyDataService,
                       SignInManager <Employee> signInManager)
 {
     _logger                 = logger;
     this.userManager        = userManager;
     this.data               = data;
     this.companyDataService = companyDataService;
     this.signInManager      = signInManager;
 }
        public void DoesCreateWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                IDepatmentDataService service = new DepatmentDataService(dbContext);

                service.Create("Design");

                Assert.AreEqual("Design", dbContext.Departments.FirstOrDefault().Name);
            }
        }
Esempio n. 6
0
        public void DoesCreateJobTitleWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                IJobTitleDataService service = new JobTittleDataServie(dbContext);

                service.CreateJobTitile("CEO");

                Assert.AreEqual("CEO", dbContext.JobTitles.FirstOrDefault().Name);
            }
        }
Esempio n. 7
0
        public void DoesFindByIdWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                IJobTitleDataService service = new JobTittleDataServie(dbContext);

                service.CreateJobTitile("CEO");

                var result = service.FindById(1).Name;

                Assert.AreEqual("CEO", result);
            }
        }
Esempio n. 8
0
        public void DoesExistsByNameWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                IJobTitleDataService service = new JobTittleDataServie(dbContext);

                service.CreateJobTitile("CEO");

                var result = service.Exists("CEO");

                Assert.IsTrue(result);
            }
        }
        public void DoesExistsByIdWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                IDepatmentDataService service = new DepatmentDataService(dbContext);

                service.Create("Design");

                var result = service.Exists(1);

                Assert.IsTrue(result);
            }
        }
        public void DoesFindByIdWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                IDepatmentDataService service = new DepatmentDataService(dbContext);

                service.Create("Design");

                var result = service.FindById(1).DepartmentName;

                Assert.AreEqual("Design", result);
            }
        }
Esempio n. 11
0
 public ManagementController(ITownDataService townDataService,
                             MDManagementDbContext data,
                             IEmployeeService employeeService,
                             IEmployeeDataService employeeDataService,
                             ICompanyDataService comapnyService,
                             UserManager <Employee> userManager,
                             IJobTitleService jobTitleService,
                             IJobTitleDataService jobTitleDataService,
                             RoleManager <IdentityRole> roleManager,
                             IDepatmentDataService depatmentDataService,
                             IAddressDataService addressDataService)
 {
     this.employeeService     = employeeService;
     this.employeeDataService = employeeDataService;
     this.comapnyService      = comapnyService;
     this.userManager         = userManager;
     this.jobTitleService     = jobTitleService;
 }
Esempio n. 12
0
 public EmployeeService(IEmployeeDataService employeeDataService,
                        IJobTitleService jobTitleService,
                        IJobTitleDataService jobTitleDataService,
                        IDepatmentDataService depatmentDataService,
                        ITownDataService townDataService,
                        IAddressDataService addressDataService,
                        MDManagementDbContext data,
                        RoleManager <IdentityRole> roleManager,
                        UserManager <Employee> userManager)
 {
     this.employeeDataService  = employeeDataService;
     this.jobTitleService      = jobTitleService;
     this.jobTitleDataService  = jobTitleDataService;
     this.depatmentDataService = depatmentDataService;
     this.townDataService      = townDataService;
     this.addressDataService   = addressDataService;
     this.data        = data;
     this.roleManager = roleManager;
     this.userManager = userManager;
 }
        public void DoesTheSerivceAddTownToTheDataBase()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                ITownDataService service = new TownDataService(dbContext);

                CreateTownServiceModel serviceModel = new CreateTownServiceModel
                {
                    Name     = "Pernik",
                    PostCode = 2300
                };

                service.Create(serviceModel);

                Assert.AreEqual("Pernik", dbContext.Towns.FirstOrDefault().Name);
            }
        }
        public void DoesFindByNameWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                ITownDataService service = new TownDataService(dbContext);

                CreateTownServiceModel serviceModel = new CreateTownServiceModel
                {
                    Name     = "Pernik",
                    PostCode = 2300
                };

                service.Create(serviceModel);

                var result = service.FindByName("Pernik").Name;

                Assert.AreEqual("Pernik", result);
            }
        }
        public void DoesExistsReturnsFalseWhenThereIsNoTown()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                ITownDataService service = new TownDataService(dbContext);

                CreateTownServiceModel serviceModel = new CreateTownServiceModel
                {
                    Name     = "Pernik",
                    PostCode = 2300
                };

                service.Create(serviceModel);

                var result = service.Exists("Pernik");

                Assert.IsTrue(result);
            }
        }
        public void DoesFindByIdWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                ICompanyDataService service = new CompanyDataSerive(dbContext);

                CreateCompanyServiceModel serviceModel = new CreateCompanyServiceModel
                {
                    Name        = "MDM",
                    Description = "No"
                };

                service.Create(serviceModel);

                var result = service.FindById(1).Name;

                Assert.AreEqual("MDM", result);
            }
        }
        public void DoesCreateWorks()
        {
            var options = new DbContextOptionsBuilder <MDManagementDbContext>()
                          .UseInMemoryDatabase(databaseName: "testDb")
                          .Options;

            using (var dbContext = new MDManagementDbContext(options))
            {
                var userManager = new Mock <UserManager <Employee> >().Object;
                IJobTitleDataService jobTitleService = new JobTittleDataServie(dbContext);
                ICompanyDataService  companyService  = new CompanyDataSerive(dbContext);
                IEmployeeDataService employeeService = new EmployeeDataService(dbContext, jobTitleService, companyService, userManager);
                IProjectDataService  projectService  = new ProjectDataService(dbContext, employeeService);

                var modelService = new ProjectServiceModel
                {
                    Name        = "AI",
                    Description = "nope",
                };

                Assert.AreEqual("AI", dbContext.Projects.FirstOrDefault().Name);
            }
        }
Esempio n. 18
0
 public TownDataService(MDManagementDbContext data)
 {
     this.data = data;
 }
Esempio n. 19
0
 public CompanyDataSerive(MDManagementDbContext data)
 {
     this.data = data;
 }
 public JobTittleDataServie(MDManagementDbContext data
                            )
 {
     this.data = data;
 }
Esempio n. 21
0
 public AddressDataService(MDManagementDbContext data)
 {
     this.data = data;
 }
Esempio n. 22
0
 public ComapnyService(ICompanyDataService companyDataService,
                       MDManagementDbContext data)
 {
     this.companyDataService = companyDataService;
     this.data = data;
 }
 public DepatmentDataService(MDManagementDbContext data)
 {
     this.data = data;
 }
Esempio n. 24
0
 public ProjectDataService(MDManagementDbContext data,
                           IEmployeeDataService employeeDataService)
 {
     this.data = data;
     this.employeeDataService = employeeDataService;
 }