Ejemplo n.º 1
0
        public void TestGetAllCenters()
        {
            CenterInputModel centerModel    = this.GetInputModel();
            CenterInputModel centerTwoModel = this.GetInputModel();

            centerTwoModel.Name = "New";

            ICenterService centerService = new CenterService(this.dbContext);

            centerService.CreateCenter(centerModel);
            centerService.CreateCenter(centerTwoModel);
            var result = centerService.GetAllCenters().Count();

            Assert.True(result != 0, "Centers count is incorrect!");
        }
Ejemplo n.º 2
0
        public void TestDeleteCenterByIncorrectId()
        {
            CenterInputModel centerModel = this.GetInputModel();

            ICenterService centerService  = new CenterService(this.dbContext);
            Center         currentlyAdded = centerService.CreateCenter(centerModel);
            Center         result         = centerService.DeleteCenterById("invalid-id-55595");

            Assert.Null(result);
        }
Ejemplo n.º 3
0
        public void TestDeleteCenterById()
        {
            CenterInputModel centerModel = this.GetInputModel();

            ICenterService centerService  = new CenterService(this.dbContext);
            Center         currentlyAdded = centerService.CreateCenter(centerModel);
            Center         result         = centerService.DeleteCenterById(currentlyAdded.Id);

            Assert.NotNull(result);
        }
Ejemplo n.º 4
0
        public void TestCreateCenterMethodShouldAddToDbCorrectly()
        {
            CenterInputModel centerModel = this.GetInputModel();

            ICenterService centerService = new CenterService(this.dbContext);
            Center         result        = centerService.CreateCenter(centerModel);
            int            entitiesCount = this.dbContext.Centers.Count();

            Assert.NotNull(result);
        }
Ejemplo n.º 5
0
        public void TestGetCenterByIdShouldWorkCorrectly()
        {
            CenterInputModel centerModel = this.GetInputModel();

            ICenterService centerService   = new CenterService(this.dbContext);
            Center         currentlyAdded  = centerService.CreateCenter(centerModel);
            Center         result          = centerService.GetCenterById(currentlyAdded.Id);
            Center         incorrectResult = centerService.GetCenterById(currentlyAdded.Id + "5");

            Assert.NotNull(result);
            Assert.Null(incorrectResult);
        }
Ejemplo n.º 6
0
        public void TestGetCenterByNameShouldWorkCorrectlyWithBothData()
        {
            CenterInputModel centerModel = this.GetInputModel();

            ICenterService centerService      = new CenterService(this.dbContext);
            Center         currentlyAdded     = centerService.CreateCenter(centerModel);
            Center         result             = centerService.GetCenterByName("SecondCenter");
            Center         resultShouldBeNull = centerService.GetCenterByName("SecondCenter1");

            Assert.NotNull(result);
            Assert.Null(resultShouldBeNull);
        }
Ejemplo n.º 7
0
        public void TestEditCenterShouldNotEditWhenFieldIsEmpty()
        {
            CenterInputModel centerModel = this.GetInputModel();

            ICenterService centerService  = new CenterService(this.dbContext);
            Center         currentlyAdded = centerService.CreateCenter(centerModel);

            centerModel.Name = "";
            centerModel.Id   = currentlyAdded.Id;
            Center result = centerService.EditCenter(centerModel);

            Assert.True(result.Name == "SecondCenter");
        }
Ejemplo n.º 8
0
        public void TestEditCenterCorrectly()
        {
            CenterInputModel centerModel = this.GetInputModel();

            ICenterService centerService  = new CenterService(this.dbContext);
            Center         currentlyAdded = centerService.CreateCenter(centerModel);

            centerModel.Name = "NameEdited";
            centerModel.Id   = currentlyAdded.Id;
            Center result = centerService.EditCenter(centerModel);

            Assert.True(result.Name == "NameEdited");
        }
Ejemplo n.º 9
0
        public void TestCreateCenterWithInvalidData()
        {
            CenterInputModel centerModel = new CenterInputModel()
            {
                Name        = "SecondCenter",
                Town        = "",
                Address     = "bul. Vasil Levski 30",
                PhoneNumber = "08742457727",
                Email       = "center2gmail.com"
            };

            Center result        = null;
            int    entitiesCount = 0;

            ICenterService centerService = new CenterService(this.dbContext);

            result        = centerService.CreateCenter(centerModel);
            entitiesCount = this.dbContext.Centers.Count();

            Assert.Null(result);
        }