public async Task GetAllEvents_WithInitialData_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "EventsService Method GetAllEvents() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.eventsService = new EventsService(context);

            List <EventServiceModel> actualResults = await this.eventsService.GetAllEvents().ToListAsync();

            List <EventServiceModel> expectedResults = GetInitialData().To <EventServiceModel>().ToList();

            for (int i = 0; i < expectedResults.Count; i++)
            {
                var expectedEntry = expectedResults[i];
                var actualEntry   = actualResults[i];

                Assert.True(expectedEntry.Name == actualEntry.Name, errorMessagePrefix + " " + "Name is not returned properly");
                Assert.True(expectedEntry.Venue == actualEntry.Venue, errorMessagePrefix + " " + "Venue is not returned properly");
                Assert.True(expectedEntry.Start.ToString("dd/MM/yyyy") == actualEntry.Start.ToString("dd/MM/yyyy"), errorMessagePrefix + " " + "StartDate is not returned properly");
                Assert.True(expectedEntry.MoreInfo == actualEntry.MoreInfo, errorMessagePrefix + " " + "MoreInfo is not returned properly");
            }
        }
        public async Task GetAllCDGDiseases_WithInitialData_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "DiseasesService Method GetAll() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);


            List <CDGDiseaseServiceModel> actualResults = await this.diseasesService.GetAll().ToListAsync();

            List <CDGDiseaseServiceModel> expectedResults = GetInitialData().To <CDGDiseaseServiceModel>().ToList();

            for (int i = 0; i < expectedResults.Count; i++)
            {
                var expectedEntry = expectedResults[i];
                var actualEntry   = actualResults[i];

                Assert.True(expectedEntry.Name == actualEntry.Name, errorMessagePrefix + " " + "Name is not returned properly");
                Assert.True(expectedEntry.Description == actualEntry.Description, errorMessagePrefix + " " + "Description is not returned properly");
                Assert.True(expectedEntry.CDGDiseaseType.Name == actualEntry.CDGDiseaseType.Name, errorMessagePrefix + " " + "CDGDiseaseType is not returned properly");
            }
        }
예제 #3
0
        public async Task GetAllArticles_WithInitialDataOrderedByAuthorNameAscending_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "ArticlesService Method GetAllArticlesByAuthorNameAscending() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.articlesService = new ArticlesService(context);


            List <ArticleServiceModel> actualResults = await this.articlesService.GetAllArticles("authorname-a-to-z").ToListAsync();

            List <ArticleServiceModel> expectedResults = context.Articles.OrderBy(a => a.Author.FullName.ToLower()).To <ArticleServiceModel>().ToList();

            for (int i = 0; i < expectedResults.Count; i++)
            {
                var expectedEntry = expectedResults[i];
                var actualEntry   = actualResults[i];

                Assert.True(expectedEntry.Title == actualEntry.Title, errorMessagePrefix + " " + "Title is not returned properly");
                Assert.True(expectedEntry.Content == actualEntry.Content, errorMessagePrefix + " " + "Content is not returned properly");
                Assert.True(expectedEntry.AuthorId == actualEntry.AuthorId, errorMessagePrefix + " " + "AuthorId is not returned properly");
                Assert.True(expectedEntry.Author.FullName.ToLower() == actualEntry.Author.FullName.ToLower(), errorMessagePrefix + " " + "AuthorFullName is not returned properly");
            }
        }
예제 #4
0
        public async Task GetAllAnswersForAQuestionById_WithCorrectData_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "AnswersService Method GetAllAnswersForQuestionById() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.answersService = new AnswersService(context);

            List <AnswerServiceModel> expectedResults = GetInitialData().Where(a => a.QuestionId == "trtsjjsch567jscj").To <AnswerServiceModel>().ToList();
            List <AnswerServiceModel> actualResults   = this.answersService.GetAllAnswersForAQuestionById("trtsjjsch567jscj")
                                                        .To <AnswerServiceModel>()
                                                        .ToList();

            Assert.True(expectedResults.Count == actualResults.Count, errorMessagePrefix);

            for (int i = 0; i < expectedResults.Count; i++)
            {
                var expectedEntry = expectedResults[i];
                var actualEntry   = actualResults[i];

                Assert.True(expectedEntry.Content == actualEntry.Content, errorMessagePrefix + " " + " Content is not returned properly");
                Assert.True(expectedEntry.QuestionId == actualEntry.QuestionId, errorMessagePrefix + " " + "QuestionId is not returned properly");
                Assert.True(expectedEntry.AuthorId == actualEntry.AuthorId, errorMessagePrefix + " " + "AuthorId is not returned properly");
            }
        }
        public async Task Edit_WithCorrectData_ShouldEditCDGDiseaseCorrectly()
        {
            string errorMessagePrefix = "DiseasesService Method Edit() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);

            CDGDiseaseServiceModel expectedData = context.CDGDiseases.First().To <CDGDiseaseServiceModel>();

            expectedData.Name                = "Edited Name";
            expectedData.Description         = "Edited Description";
            expectedData.CDGDiseaseType.Name = "Edited Type";

            await this.diseasesService.Edit(expectedData.Id, expectedData);

            CDGDiseaseServiceModel actualData = context.CDGDiseases.First().To <CDGDiseaseServiceModel>();

            Assert.True(actualData.Name == expectedData.Name, errorMessagePrefix + "Name not edited properly");
            Assert.True(actualData.Description == expectedData.Description, errorMessagePrefix + "Description not edited properly");

            Assert.True(actualData.CDGDiseaseType.Name == expectedData.CDGDiseaseType.Name, errorMessagePrefix + "CDGDiseaseType not edited properly");
        }
예제 #6
0
        public async Task Delete_WithGivenNonExistenId_ShouldThrowArgumentNullException()
        {
            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.articlesService = new ArticlesService(context);
            await Assert.ThrowsAsync <ArgumentNullException>(() => this.articlesService.Delete("Non-Existent"));
        }
        public async Task GetAllEvents_WithZeroData_ShouldReturnEmptyResult()
        {
            string errorMessagePrefix = "EventsService Method GetAllEvents() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            this.eventsService = new EventsService(context);

            List <EventServiceModel> actualResults = await this.eventsService.GetAllEvents().ToListAsync();

            Assert.True(actualResults.Count == 0, errorMessagePrefix);
        }
        public async Task GetAllCDGDiseaseTypes_WithZeroData_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "DiseasesService GetAllCDGTypes() method does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);

            List <CDGDiseaseTypeServiceModel> actualResults = await this.diseasesService.GetAllTypes().ToListAsync();

            Assert.True(actualResults.Count == 0, errorMessagePrefix);
        }
        public async Task GetDiseaseById_WithNonExistentId_ShouldReturnNull()
        {
            string errorMessagePrefix = "DiseaseService Method GetDiseaseById() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);

            CDGDiseaseServiceModel actualResult = await this.diseasesService.GetCDGDiseaseById(1000);

            Assert.True(actualResult == null, errorMessagePrefix);
        }
예제 #10
0
        public async Task GetAllAnswersForAQuestionById_WithNonExistentQuestionId_ShouldReturnZeroCount()
        {
            string errorMessagePrefix = "AnswersService Method GetAllAnswersForAQuestionById() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.answersService = new AnswersService(context);

            List <AnswerServiceModel> actualResult = await this.answersService.GetAllAnswersForAQuestionById("fake1").ToListAsync();

            Assert.True(actualResult.Count == 0, errorMessagePrefix);
        }
예제 #11
0
        public async Task Edit_WithCorrectData_ShouldPassSuccesfully()
        {
            string errorMessagePrefix = "ArticlesService Method Edit() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.articlesService = new ArticlesService(context);

            ArticleServiceModel expectedData = context.Articles.First().To <ArticleServiceModel>();

            bool actualData = await this.articlesService.Edit(expectedData.Id, expectedData);

            Assert.True(actualData, errorMessagePrefix);
        }
        public async Task Delete_WithCorrectData_ShouldPassSuccesfully()
        {
            string errorMessagePrefix = "DiseasesService Method Delete() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);

            CDGDiseaseServiceModel expectedData = context.CDGDiseases.First().To <CDGDiseaseServiceModel>();

            bool actualData = await this.diseasesService.Delete(expectedData.Id);

            Assert.True(actualData, errorMessagePrefix);
        }
        public async Task CreateDiseaseType_WithCorrectData_ShouldSuccesfullyCreate()
        {
            string errorMessagePrefix = "DiseasesService Method CreateDisease() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            this.diseasesService = new DiseasesService(context);

            CDGDiseaseTypeServiceModel diseaseTypeServiceModel = new CDGDiseaseTypeServiceModel()
            {
                Name = "Mixed-Type"
            };

            bool actualResult = await this.diseasesService.CreateDiseaseType(diseaseTypeServiceModel);

            Assert.True(actualResult, errorMessagePrefix);
        }
        public async Task Create_WithCorrectData_ShouldSuccesfullyCreate()
        {
            string errorMessagePrefix = "FactsService Method CreateEvent() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            this.factsService = new FactsService(context);

            FactServiceModel factus = new FactServiceModel()
            {
                Content = "There are not yet found medicines for this desease.",
                PdfFile = "src/pics/something/sofia.pdf"
            };

            bool actualResult = await this.factsService.Create(factus);

            Assert.True(actualResult, errorMessagePrefix);
        }
        public async Task Edit_WithGivenNonExistenId_ShouldThrowArgumentNullException()
        {
            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);

            CDGDiseaseServiceModel expectedData = context.CDGDiseases.First().To <CDGDiseaseServiceModel>();

            expectedData.Name                = "Edited Name";
            expectedData.Description         = "Edited Description";
            expectedData.CDGDiseaseType.Name = "Edited Type";

            await this.diseasesService.Edit(expectedData.Id, expectedData);

            await Assert.ThrowsAsync <ArgumentNullException>(() => this.diseasesService.Edit(205, expectedData));
        }
예제 #16
0
        public async Task Create_WithCorrectData_ShouldSuccesfullyCreate()
        {
            string errorMessagePrefix = "QuestionsService Method CreateQuestion() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            this.questionsService = new QuestionsService(context);

            QuestionServiceModel questionModel = new QuestionServiceModel()
            {
                Content   = "Are there really found medicines for this desease?",
                AuthorId  = "trahjgtss123",
                CreatedOn = DateTime.Parse("10/07/2019 10:30"),
            };

            bool actualResult = await this.questionsService.Create(questionModel);

            Assert.True(actualResult, errorMessagePrefix);
        }
        public async Task GetDiseaseById_WithExistentId_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "DiseaseService Method GetDiseaseById() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);

            var expectedResult = context.CDGDiseases.First();

            CDGDiseaseServiceModel actualResult = await this.diseasesService.GetCDGDiseaseById(expectedResult.Id);

            Assert.True(expectedResult.Id == actualResult.Id, errorMessagePrefix + " " + "Id is not returned properly");
            Assert.True(expectedResult.Name == actualResult.Name, errorMessagePrefix + " " + "Name is not returned properly");
            Assert.True(expectedResult.Description == actualResult.Description, errorMessagePrefix + " " + "Name is not returned properly");
            Assert.True(expectedResult.CDGDiseaseType.Name == actualResult.CDGDiseaseType.Name, errorMessagePrefix + " " + "CDGDiseaseType is not returned properly");
        }
        public async Task Delete_WithCorrectData_ShouldDeleteFromContext()
        {
            string errorMessagePrefix = "CDGDiseasesService Method Delete() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);

            int idToDelete = context.CDGDiseases.First().To <CDGDiseaseServiceModel>().Id;

            await this.diseasesService.Delete(idToDelete);

            int expectedCount = 1;
            int actualCount   = context.CDGDiseases.Count();

            Assert.True(expectedCount == actualCount, errorMessagePrefix);
        }
예제 #19
0
        public async Task Create_WithCorrectData_ShouldSuccesfullyCreate()
        {
            string errorMessagePrefix = "AnswersService Method CreateAnswer() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.answersService = new AnswersService(context);

            AnswerServiceModel answerServiceModel = new AnswerServiceModel()
            {
                Content    = "Sofia is the place, where the association is founded.",
                QuestionId = "dfghrf3456"
            };

            bool actualResult = await this.answersService.CreateAnswer(answerServiceModel);

            Assert.True(actualResult, errorMessagePrefix);
        }
        public async Task Create_WithCorrectData_ShouldSuccesfullyCreate()
        {
            string errorMessagePrefix = "EventsService Method CreateEvent() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            this.eventsService = new EventsService(context);

            EventServiceModel eve = new EventServiceModel()
            {
                Name     = "CDGHealthMeeting",
                Venue    = "Sofia",
                Start    = DateTime.ParseExact("05/03/2019 14:00", "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture),
                MoreInfo = "src/pics/something/sofia.pdf"
            };

            bool actualResult = await this.eventsService.Create(eve);

            Assert.True(actualResult, errorMessagePrefix);
        }
예제 #21
0
        public async Task Create_WithCorrectData_ShouldSuccesfullyCreate()
        {
            string errorMessagePrefix = "ArticlesService Method CreateArticle() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.articlesService = new ArticlesService(context);

            ArticleServiceModel articleServiceModel = new ArticleServiceModel()
            {
                Title   = "CDGHealthMeeting",
                Content = "Sofia is the place, where the association is founded.",
            };

            bool actualResult = await this.articlesService.CreateArticle(articleServiceModel);

            Assert.True(actualResult, errorMessagePrefix);
        }
        public async Task Edit_WithNonExistentDiseaseType_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "DiseasesService Edit() method does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.diseasesService = new DiseasesService(context);

            CDGDiseaseServiceModel expectedData = context.CDGDiseases.First().To <CDGDiseaseServiceModel>();

            expectedData.Name           = "Editted_Name";
            expectedData.CDGDiseaseType = new CDGDiseaseTypeServiceModel
            {
                Name = "Non-Existent"
            };

            await Assert.ThrowsAsync <ArgumentNullException>(() => this.diseasesService.Edit(expectedData.Id, expectedData));
        }
예제 #23
0
        public async Task Edit_WithGivenNonExistenId_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "ArticlesService Method Edit() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.articlesService = new ArticlesService(context);

            ArticleServiceModel expectedData = context.Articles.First().To <ArticleServiceModel>();

            expectedData.Title     = "Edited Title";
            expectedData.Content   = "Edited Content";
            expectedData.CreatedOn = DateTime.UtcNow;
            expectedData.AuthorId  = "gfbehs";

            await this.articlesService.Edit(expectedData.Id, expectedData);

            await Assert.ThrowsAsync <ArgumentNullException>(() => this.articlesService.Edit("Non-Existent", expectedData));
        }
예제 #24
0
        public async Task Edit_WithCorrectData_ShouldEditArticleCorrectly()
        {
            string errorMessagePrefix = "ArticlesService Method Edit() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.articlesService = new ArticlesService(context);

            ArticleServiceModel expectedData = context.Articles.First().To <ArticleServiceModel>();

            expectedData.Title   = "Edited Title";
            expectedData.Content = "Edited Content";

            await this.articlesService.Edit(expectedData.Id, expectedData);

            ArticleServiceModel actualData = context.Articles.First().To <ArticleServiceModel>();

            Assert.True(actualData.Title == expectedData.Title, errorMessagePrefix + "Title not edited properly");
            Assert.True(actualData.Content == expectedData.Content, errorMessagePrefix + "Content not edited properly");
        }
예제 #25
0
        public async Task GetAllQuestions_WithInitialData_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "QuestionsService Method GetAllQuestions() does not work properly.";

            var context = CDGBulgariaInmemoryFactory.InitializeContext();

            await SeedData(context);

            this.questionsService = new QuestionsService(context);

            List <QuestionServiceModel> actualResults = await this.questionsService.GetAllQuestions().ToListAsync();

            List <QuestionServiceModel> expectedResults = GetInitialData().To <QuestionServiceModel>().ToList();

            for (int i = 0; i < expectedResults.Count; i++)
            {
                var expectedEntry = expectedResults[i];
                var actualEntry   = actualResults[i];

                Assert.True(expectedEntry.Content == actualEntry.Content, errorMessagePrefix + " " + "Content is not returned properly");
                Assert.True(expectedEntry.Author.UserName == actualEntry.Author.UserName, errorMessagePrefix + " " + "AuthorUsername is not returned properly");
            }
        }