Exemplo n.º 1
0
        public Lib.Models.Division GetTestData(CoreDbContext dbContext)
        {
            Lib.Models.Division data = new Lib.Models.Division();
            dbContext.Divisions.Add(data);
            dbContext.SaveChanges();

            return(data);
        }
Exemplo n.º 2
0
        public async Task Update()
        {
            Lib.Models.Division division = await DataUtil.GetTestDataAsync();

            DivisionViewModel VM = Service.MapToViewModel(division);
            var response         = await this.Client.PutAsync(string.Concat(URI, "/", VM.Id), new StringContent(JsonConvert.SerializeObject(VM).ToString(), Encoding.UTF8, "application/json"));

            Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
        }
Exemplo n.º 3
0
        public async Task Delete()
        {
            Lib.Models.Division division = await DataUtil.GetTestDataAsync();

            DivisionViewModel VM = Service.MapToViewModel(division);
            var response         = await this.Client.DeleteAsync(string.Concat(URI, "/", VM.Id));

            Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
        }
Exemplo n.º 4
0
        public async Task TestJoinDivision()
        {
            CategoryService service         = this.Service;
            DivisionService divisionService = ServiceProvider.GetService <DivisionService>();
            string          guid            = Guid.NewGuid().ToString();

            var division = new Lib.Models.Division()
            {
                Name = String.Concat("TEST DIVISION ", guid),
            };
            Category createdData = await this.GetCreatedTestData(service);

            var createdDivision = await divisionService.CreateModel(division);

            var data = service.JoinDivision();

            Assert.NotNull(data);
        }
Exemplo n.º 5
0
        public void GetDivisionName_Return_OK()
        {
            //Setup
            CoreDbContext           dbContext       = _dbContext(GetCurrentAsyncMethod());
            Mock <IServiceProvider> serviceProvider = GetServiceProvider();

            DivisionService service = new DivisionService(serviceProvider.Object);

            serviceProvider.Setup(s => s.GetService(typeof(DivisionService))).Returns(service);
            serviceProvider.Setup(s => s.GetService(typeof(CoreDbContext))).Returns(dbContext);

            Lib.Models.Division testData = GetTestData(dbContext);

            //Act
            IActionResult response = GetController(service).GetByDivisionName();

            //Assert
            int statusCode = this.GetStatusCode(response);

            Assert.NotEqual((int)HttpStatusCode.NotFound, statusCode);
        }