Esempio n. 1
0
        public void GetTutorialsPaged_Success_Test()
        {
            // Arrange
            string searchTerm = "";
            int    pageIndex  = 0;
            int    pageSize   = 10;

            // list
            IList <R_Tutorial> list = new List <R_Tutorial>();

            for (int i = 1; i <= pageSize; i++)
            {
                list.Add(SampleTutorial(i));
            }

            // create mock for repository
            var mock = new Mock <ITutorialRepository>();

            mock.Setup(s => s.GetTutorials(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list);

            // service
            TutorialService tutorialService = new TutorialService();

            TutorialService.Repository = mock.Object;

            // Act
            var         resultList = tutorialService.GetTutorials(searchTerm, pageIndex, pageSize);
            TutorialDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.TutorialId);
            Assert.AreEqual(10, resultList.Count);
        }
        public async Task Edit_WithValidData_ShouldSaveUpdatedTurorial()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            var tutorial = await repo.GetByIdAsync(2);

            db.Entry(tutorial).State = EntityState.Detached;
            var model = this.Mapper.Map <Tutorial, AddTutorialViewModel>(tutorial);

            model.Title = "Golden leaf";

            //Act
            await service.UpdateTutorial(model);

            var expectedTitle = "Golden leaf";
            var actualTitle   = repo.All().SingleOrDefault(t => t.Id == 2).Title;

            //Assert
            Assert.Equal(expectedTitle, actualTitle);
        }
Esempio n. 3
0
    public void Start()
    {
        TutorialService.CheckTutorial("Activities");
        TutorialService.CheckParentalAlert();

        previousView = "Home";
    }
Esempio n. 4
0
        public bool HandleTouchUp(Vector3 screenPos)
        {
            if (!isTapOnUI)
            {
                var touched = Utils.GetInputTargetOnGrid(screenPos, sceneSystem, cameraService.activeCamera, gridService);
                if (touched != null && (!touched.hasGrid || (touched.hasGrid && touched.grid.cells.Count > 0)))
                {
                    EventDispatcherService <GameEntity> .Dispatch(Constants.EVENT_ENTITY_TAP_UP, touched);

                    if (touched.hasGameObject)
                    {
                        TutorialService <TutorialStep> .Notify(string.Format("tap?{0}", touched.objectId));
                    }

                    if (touched.hasCommand && !string.IsNullOrEmpty(touched.command.onTapCommand))
                    {
                        var cell = touched.hasGrid ? touched.grid.pivot : null;
                        commandSystem.Execute(touched.command.onTapCommand, touched.position, cell, touched);
                        AnimateObjectTouch(touched);
                    }
                }
            }
            isTapOnUI = false;
            return(false);
        }
Esempio n. 5
0
        public void GetTutorials_Success_Test()
        {
            // Arrange
            R_Tutorial tutorial = SampleTutorial(1);

            IList <R_Tutorial> list = new List <R_Tutorial>();

            list.Add(tutorial);

            // create mock for repository
            var mock = new Mock <ITutorialRepository>();

            mock.Setup(s => s.GetTutorials()).Returns(list);

            // service
            TutorialService tutorialService = new TutorialService();

            TutorialService.Repository = mock.Object;

            // Act
            var         resultList = tutorialService.GetTutorials();
            TutorialDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.TutorialId);
        }
    public void Start()
    {
        TutorialService.CheckTutorial("Plants");

        previousView = "Login";
        plantCard.SetActive(false);

        StartCoroutine(_GetPlantTypes());
    }
Esempio n. 7
0
    public void Start()
    {
        currentTab   = "Home";
        photoTexture = UserService.user.profilePicture;

        TutorialService.CheckTutorial("Welcome");

        UpdateAndShowUser();
    }
    public void Start()
    {
        TutorialService.CheckTutorial("Missions");

        previousView = "Home";
        missionCard.SetActive(false);
        noMissionsCard.SetActive(false);

        StartCoroutine(_GetMissions());
    }
Esempio n. 9
0
    public void Start()
    {
        TutorialService.CheckTutorial("Quizzes");

        previousView = "Home";
        quizCard.SetActive(false);
        noQuizzesCard.SetActive(false);

        StartCoroutine(_GetQuizzes());
    }
Esempio n. 10
0
        public void GetTutorialListAdvancedSearch_Success_Test()
        {
            // Arrange
            string name             = null;
            string description      = null;
            string location         = null;
            bool?  isOnlineTutorial = null;
            string language         = null;
            bool?  active           = null;

            //int pageIndex = 0;
            int pageSize = 10;

            // list
            IList <R_Tutorial> list = new List <R_Tutorial>();

            for (int i = 1; i <= pageSize; i++)
            {
                list.Add(SampleTutorial(i));
            }

            // create mock for repository
            var mock = new Mock <ITutorialRepository>();

            mock.Setup(s => s.GetTutorialListAdvancedSearch(
                           Moq.It.IsAny <string>()   // name
                           , Moq.It.IsAny <string>() // description
                           , Moq.It.IsAny <string>() // location
                           , Moq.It.IsAny <bool?>()  // isOnlineTutorial
                           , Moq.It.IsAny <string>() // language
                           , Moq.It.IsAny <bool?>()  // active
                           )).Returns(list);

            // service
            TutorialService tutorialService = new TutorialService();

            TutorialService.Repository = mock.Object;

            // Act
            var resultList = tutorialService.GetTutorialListAdvancedSearch(
                name
                , description
                , location
                , isOnlineTutorial
                , language
                , active
                );

            TutorialDTO result = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.TutorialId);
        }
    public void Start()
    {
        TutorialService.CheckTutorial("Groups");

        previousView = "Home";
        groupCard.SetActive(false);
        noGroupsCard.SetActive(false);
        newGroupCard.SetActive(false);

        StartCoroutine(_GetGroups());
    }
Esempio n. 12
0
    public void Start()
    {
        TutorialService.CheckTutorial("Timeline");

        previousView = "Home";

        postCard.SetActive(false);
        NMPostCard.SetActive(false);
        noPostsCard.SetActive(false);
        moreCard.SetActive(false);

        StartCoroutine(_GetTimelinePosts());
    }
        public async Task AddRatingToTutorial_WithInValidRating_ShouldThrow()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo    = new Repository <Tutorial>(db);
            var service = new TutorialService(repo, this.Mapper, null);

            //Act

            //Assert
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.AddRatingToTutorial(2, 6));
        }
        public void GetTutorials_WithNoTutorialsInTheDb_ShouldReturnEmpty()
        {
            //Arrange
            var db = this.SetDb();

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act
            var tutorials = service.GetTutorials();

            //Assert
            Assert.Empty(tutorials);
        }
        public async Task GetTutorialById_WithInValidId_ShouldThrow()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act

            //Assert
            await Assert.ThrowsAsync <NullReferenceException>(async() => await service.GetTutorialById(3));
        }
        public async Task DeleteTutorial_WithInValidiD_ShouldDoNating()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act

            //Asser
            await Assert.ThrowsAsync <NullReferenceException>(async() => await service.DeleteTutorial(3));
        }
        public async Task AddRatingToTutorial_WithNullTutorial_ShoulThrow()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act

            //Assert
            await Assert.ThrowsAsync <NullReferenceException>(async() => await service.AddRatingToTutorial(3, -5));
        }
        public async Task GetTutorials_WithAddedTutorialsInTheDb_ShouldReturnCollectionOfTurorials()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act
            var tutorials = service.GetTutorials();

            //Assert
            Assert.NotEmpty(tutorials);
        }
Esempio n. 19
0
        protected virtual void ExecuteHeadCommand(CommandData commandData, Vector3 executePos, GameEntity cell, GameEntity trigger = null)
        {
            if (commandData.destroyTrigger && trigger != null)
            {
                if (trigger.hasCommand)
                {
                    commandSystem.Execute(trigger.command.onDestroyCommand, executePos, cell, trigger);
                }

                gridService.DeAttach(trigger);

                trigger.Destroy();
            }

            if (!string.IsNullOrEmpty(commandData.tutorialTrigger))
            {
                TutorialService <TutorialStep> .Notify(commandData.tutorialTrigger);
            }
        }
        public async Task AddRatingToTutorial_WithValidData_ShouldAddRatingToTutorial()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo    = new Repository <Tutorial>(db);
            var service = new TutorialService(repo, this.Mapper, null);

            //Act
            await service.AddRatingToTutorial(2, 5);

            var expectedRate = 5;
            var actualRate   = repo.All().SingleOrDefault(p => p.Id == 2).Rating;

            //Assert
            Assert.Equal(expectedRate, actualRate);
        }
Esempio n. 21
0
        public void DeleteTutorialById_Success_Test()
        {
            // Arrange
            int id = 1;

            // create mock for repository
            var mock = new Mock <ITutorialRepository>();

            mock.Setup(s => s.DeleteTutorial(Moq.It.IsAny <int>())).Verifiable();

            // service
            TutorialService tutorialService = new TutorialService();

            TutorialService.Repository = mock.Object;

            // Act
            tutorialService.DeleteTutorial(id);

            // Assert
            Assert.IsTrue(true);
        }
Esempio n. 22
0
        public void UpdateTutorial_Success_Test()
        {
            // Arrange
            TutorialDTO dto = SampleTutorialDTO(1);

            // create mock for repository
            var mock = new Mock <ITutorialRepository>();

            mock.Setup(s => s.UpdateTutorial(Moq.It.IsAny <R_Tutorial>())).Verifiable();

            // service
            TutorialService tutorialService = new TutorialService();

            TutorialService.Repository = mock.Object;

            // Act
            tutorialService.UpdateTutorial(dto);

            // Assert
            Assert.IsNotNull(dto);
        }
        public async Task GetTutorialById_WithValidId_ShouldReturnModel()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act
            var model = await service.GetTutorialById(2);

            var expectedId = 2;
            var actualId   = model.Id;

            //Assert
            Assert.NotNull(model);
            Assert.Equal(expectedId, actualId);
        }
Esempio n. 24
0
        public void AddTutorial_Success_Test()
        {
            // Arrange
            TutorialDTO dto = SampleTutorialDTO(1);

            // create mock for repository
            var mock = new Mock <ITutorialRepository>();

            mock.Setup(s => s.AddTutorial(Moq.It.IsAny <R_Tutorial>())).Returns(1);

            // service
            TutorialService tutorialService = new TutorialService();

            TutorialService.Repository = mock.Object;

            // Act
            int id = tutorialService.AddTutorial(dto);

            // Assert
            Assert.AreEqual(1, id);
            Assert.AreEqual(1, dto.TutorialId);
        }
        public async Task AddRatingToTutorial_WithAddingRate_ShoulIncreaseRatingVotes()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act
            await service.AddRatingToTutorial(2, 5);

            await service.AddRatingToTutorial(2, 3);

            var expectedRatingVotes = 2;
            var actualRatingVotes   = repo.All().SingleOrDefault(p => p.Id == 2).RatingVotes;

            //Assert
            Assert.Equal(expectedRatingVotes, actualRatingVotes);
        }
        public async Task AddTutorial_WithValidModel_ShouldBeSuccessful()
        {
            //Arrange
            var db = this.SetDb();

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            var model = new AddTutorialViewModel {
                Title = "Lotus Flower", Description = "Lotus Test Descripion", Url = "https://someurl.bg"
            };

            //Act
            await service.AddTutorial(model);

            var expectedTutorialsCount = 1;
            var actualTutorialsCount   = repo.All().Count();

            //Assert
            Assert.Equal(expectedTutorialsCount, actualTutorialsCount);
        }
        public async Task Edit_WithDuplicateTitle_ShouldSaveUpdatedTurorialThrow()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            var tutorial = await repo.GetByIdAsync(2);

            db.Entry(tutorial).State = EntityState.Detached;
            var model = this.Mapper.Map <Tutorial, AddTutorialViewModel>(tutorial);

            model.Title = "Lotus Flower";

            //Act

            //Assert
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.UpdateTutorial(model));
        }
Esempio n. 28
0
        public void GetTutorial_Success_Test()
        {
            // Arrange
            int        id       = 1;
            R_Tutorial tutorial = SampleTutorial(id);

            // create mock for repository
            var mock = new Mock <ITutorialRepository>();

            mock.Setup(s => s.GetTutorial(Moq.It.IsAny <int>())).Returns(tutorial);

            // service
            TutorialService tutorialService = new TutorialService();

            TutorialService.Repository = mock.Object;

            // Act
            TutorialDTO result = tutorialService.GetTutorial(id);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.TutorialId);
        }
        public async Task AddTutorial_WithDuplicateTitle_ShouldTrow()
        {
            //Arrange
            var db = this.SetDb();

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            var model1 = new AddTutorialViewModel {
                Title = "Lotus Flower", Description = "Lotus Test Descripion", Url = "https://someurl.bg"
            };
            var model2 = new AddTutorialViewModel {
                Title = "Lotus Flower", Description = "Lotus Test Descripion", Url = "https://otherurl.bg"
            };

            await service.AddTutorial(model1);

            //Act

            //Assert
            await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.AddTutorial(model2));
        }
        public async Task DeleteTutorial_WithValidiD_ShouldDeleteTheTutorial()
        {
            //Arrange
            var db = this.SetDb();

            await this.SeedTutorials(db);

            var repo = new Repository <Tutorial>(db);

            var service = new TutorialService(repo, this.Mapper, null);

            //Act
            await service.DeleteTutorial(1);

            var expectedRepoCount = 1;
            var actualRepoCount   = repo.All().Count();

            var expectedTutorialId = 2;
            var actualTutorialId   = repo.All().First().Id;

            //Asser
            Assert.Equal(expectedRepoCount, actualRepoCount);
            Assert.Equal(expectedTutorialId, actualTutorialId);
        }