예제 #1
0
        public void CallArtistServiceMethodGetArtists_WhenInvoked()
        {
            // Arrange
            var createService = new Mock <ICreationService>();
            var artistService = new Mock <IArtistService>();
            var albumService  = new Mock <IAlbumService>();
            var genreService  = new Mock <IGenreService>();

            var artist = new Artist()
            {
                Name = "Artist Name"
            };

            var artistCollection = new List <Artist>()
            {
                artist
            };

            artistService.Setup(x => x.GetArtists()).Returns(() => artistCollection.AsQueryable());

            var sut = new CreateController(
                createService.Object,
                artistService.Object,
                albumService.Object,
                genreService.Object);

            // Act
            sut.CreateAlbum();

            // Assert
            artistService.Verify(x => x.GetArtists(), Times.Once);
        }
        public void CallCreateServiceMethodCreateArtistOnce_WhenInvoked()
        {
            // Arrange
            var createService = new Mock <ICreationService>();
            var artistService = new Mock <IArtistService>();
            var albumService  = new Mock <IAlbumService>();
            var genreService  = new Mock <IGenreService>();

            createService.Setup(x => x.CreateArtist(It.IsAny <string>()));

            var sut = new CreateController(
                createService.Object,
                artistService.Object,
                albumService.Object,
                genreService.Object);

            var model = new CreateArtistViewModel()
            {
                Name = "Artist Name"
            };

            // Act
            sut.CreateArtist(model);

            // Assert
            createService.Verify(x => x.CreateArtist(It.IsAny <string>()), Times.Once);
        }
예제 #3
0
 public CreateControllerTest()
 {
     this._serviceProviderMock                      = new ServiceProviderMock();
     this._controller                               = new CreateController(this._serviceProviderMock.getMock());
     this._controller.ControllerContext             = new ControllerContext();
     this._controller.ControllerContext.HttpContext = new DefaultHttpContext();
 }
예제 #4
0
        public CreateControllerTests()
        {
            mediator   = A.Fake <IMediator>();
            controller = new CreateController(mediator);
            var movementRulesSummary = new MovementRulesSummary(new List <RuleResult <MovementRules> >());

            A.CallTo(() => mediator.SendAsync(A <GetMovementRulesSummary> .Ignored)).Returns(movementRulesSummary);
            A.CallTo(() => mediator.SendAsync(A <GetShipmentInfo> .Ignored)).Returns(GetShipmentInfo());
        }
        public void Test_EnsureAuthorised_AllowPublicType()
        {
            CreateController controller = new CreateController();

            controller.Container = new MockCreateProjection(typeof(MockPublicEntity));
            bool isAuthorised = controller.EnsureAuthorised();

            Assert.IsTrue(isAuthorised, "Returned false when it should be true.");
        }
        /// <summary>
        /// Starts the process of creating a new entity without any default values.
        /// </summary>
        public virtual void Create()
        {
            using (LogGroup logGroup = LogGroup.Start("Creating a new entity.", NLog.LogLevel.Debug))
            {
                CheckCreateController();

                Create(CreateController.Create());
            }
        }
예제 #7
0
        public void Test_IsController()
        {
            ControllerScanner scanner = new ControllerScanner();

            CreateController controller = new CreateController();

            bool isController = scanner.IsController(controller.GetType());

            Assert.IsTrue(isController, "CreateController class is not recognised as a controller as it should be.");
        }
        public void Index_TestIndexView_ViewResult()
        {
            //Arrange
            CreateController controller = new CreateController();

            //Act
            ViewResult result = controller.Index() as ViewResult;

            //Assert
            Assert.AreEqual("Index", result.ViewName);
        }
        public void Test_EnsureAuthorised_RestrictUnauthorisedType()
        {
            MockRestrictedEntity restrictedEntity = new MockRestrictedEntity();

            CreateController controller = new CreateController();

            controller.Container = new MockCreateProjection(typeof(MockRestrictedEntity));
            bool isAuthorised = controller.EnsureAuthorised();

            Assert.IsFalse(isAuthorised, "Returned true when it should have been false.");
        }
        /// <summary>
        /// Saves the provided entity.
        /// Note: PrepareSave must be called before using this function.
        /// </summary>
        /// <returns></returns>
        public virtual bool Save(IEntity entity)
        {
            bool success = false;

            using (LogGroup logGroup = LogGroup.Start("Saving the provided entity.", NLog.LogLevel.Debug))
            {
                if (Page.IsValid)
                {
                    success = CreateController.Save(entity);
                }
            }
            return(success);
        }
 public void InitializeControllers()
 {
     if (Array.IndexOf(Command.AllActions, "Create") > -1)
     {
         createController = CreateController.New(this, UniquePropertyName);
         Controllers.Add(createController);
     }
     else
     {
         editController = EditController.New(this, UniquePropertyName);
         Controllers.Add(editController);
     }
 }
        /// <summary>
        /// Starts the process of creating a new entity using the provided entity as the default field values.
        /// </summary>
        /// <param name="entity"></param>
        public virtual void Create(IEntity entity)
        {
            using (LogGroup logGroup = LogGroup.Start("Preparing a create action.", NLog.LogLevel.Debug))
            {
                CheckCreateController();

                DataSource      = entity;
                Form.DataSource = entity;

                CreateController.Create(entity);

                DataBind();
            }
        }
        public void CallCreateServiceMethodCreateSong_WhenInvoked()
        {
            // Arrange
            var createService = new Mock <ICreationService>();
            var artistService = new Mock <IArtistService>();
            var albumService  = new Mock <IAlbumService>();
            var genreService  = new Mock <IGenreService>();

            createService.Setup(x => x.CreateSong(
                                    It.IsAny <string>(),
                                    It.IsAny <string>(),
                                    It.IsAny <string>(),
                                    It.IsAny <int?>(),
                                    It.IsAny <ICollection <string> >(),
                                    It.IsAny <string>(),
                                    It.IsAny <string>()));

            var sut = new CreateController(
                createService.Object,
                artistService.Object,
                albumService.Object,
                genreService.Object);

            var model = new CreateSongViewModel()
            {
                Title    = "Title",
                Artist   = "Artist",
                Album    = "Album",
                Duration = 5,
                Genres   = new List <string>()
                {
                    "Genre"
                },
                Lyrics   = "Lyrics",
                VideoUrl = "VideoUrl",
            };

            // Act
            sut.CreateSong(model);

            // Assert
            createService.Verify(x => x.CreateSong(
                                     It.IsAny <string>(),
                                     It.IsAny <string>(),
                                     It.IsAny <string>(),
                                     It.IsAny <int?>(),
                                     It.IsAny <ICollection <string> >(),
                                     It.IsAny <string>(),
                                     It.IsAny <string>()), Times.Once);
        }
예제 #14
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            //打开日志窗体
            logForm log = logForm.InstanceLogForm();

            log.Show();
            log.Visible = false;
            //设置数据
            CheckForIllegalCrossThreadCalls = false;
            List <QuestionaireEntity> dataList = QuestionaireData.getData();

            for (int i = 0; i < dataList.Count; i++)
            {
                CreateController.addController(10, (1 + i) * 35, this, dataList[i]);
            }
        }
예제 #15
0
    void onTouchEvent(string obj)
    {
        Buy.name = items.Item.ToString();

        if (obj == Buy.name)
        {
            if (TouchController.collider.tag != "Utilits")
            {
                CreateController.shareCreate().createBuyLevelUp(this);
            }
            else
            {
                CreateController.shareCreate().createBuyUtilits(this);
            }
        }
    }
예제 #16
0
        public void Test_Create_Parent()
        {
            MockProjection projection = new MockProjection();

            projection.RequireAuthorisation = false;
            projection.Command = new CreateComandInfo(typeof(TestArticlePage).Name);

            TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>();

            article.ID    = Guid.NewGuid();
            article.Title = "Test title";

            SaveStrategy.New <TestArticle>(false).Save(article);

            CreateController controller = CreateController.New(projection);

            Assert.IsTrue(controller is CreateSubEntityController, "Invalid controller type: " + controller.GetType().ToString());

            CreateSubEntityController createSubEntityController = (CreateSubEntityController)controller;

            ISubEntity subEntity = (ISubEntity)createSubEntityController.Create(article.ID, String.Empty);

            Assert.IsNotNull(subEntity, "No sub entity returned.");

            Assert.IsTrue((subEntity is TestArticlePage), "Wrong type returned: " + subEntity.GetType().ToString());

            Assert.IsNotNull(subEntity.Parent, "No parent assigned to sub entity.");

            Assert.AreEqual(article.ID.ToString(), subEntity.Parent.ID.ToString(), "Parent ID doesn't match expected.");

            Assert.AreEqual(1, subEntity.Number, "Sub entity has wrong number.");

            SaveStrategy.New(subEntity, false).Save(subEntity);


            ISubEntity subEntity2 = (ISubEntity)createSubEntityController.Create(Guid.Empty, article.UniqueKey);

            Assert.IsNotNull(subEntity2, "No sub entity returned.");

            Assert.IsTrue((subEntity2 is TestArticlePage), "Wrong type returned: " + subEntity.GetType().ToString());

            Assert.IsNotNull(subEntity2.Parent, "No parent assigned to sub entity.");

            Assert.AreEqual(article.ID.ToString(), subEntity2.Parent.ID.ToString(), "Parent ID doesn't match expected.");

            Assert.AreEqual(2, subEntity2.Number, "Sub entity has wrong number.");
        }
        private void CreateButton_Click(object sender, EventArgs e)
        {
            var     username   = UserLabel.Text;
            var     g          = Guid.NewGuid();
            var     date       = dateTimePicker.Value;
            string  GT         = GroupTitleTextBox.Text;
            int     duration   = Convert.ToInt32(meetingDurationtextBox.Text);
            string  loc        = locaitonTextBox.Text;
            Meeting newMeeting = new Meeting()
            {
                Id = g, GroupTitle = GT, MeetingDate = date, MeetingDuration = duration, MeetingLocation = loc, UserN = username
            };

            CreateController create = new CreateController();

            create.createMeeting(newMeeting);
            this.Close();
            //then update the caledar on home screen with meeting
        }
        /// <summary>
        /// Saves the entity from the form.
        /// </summary>
        /// <returns></returns>
        public virtual bool Save()
        {
            bool success = false;

            using (LogGroup logGroup = LogGroup.Start("Saving the entity from the form.", NLog.LogLevel.Debug))
            {
                if (Page.IsValid)
                {
                    PrepareSave();

                    if (DataSource == null)
                    {
                        throw new Exception("DataSource == null. Call PrepareSave().");
                    }

                    success = CreateController.Save(DataSource);
                }
            }
            return(success);
        }
        public void Forum_CreateController_Index_Post_ShouldCallRedirectToActionWithCorrectRouteParams()
        {
            //Arrange
            var data             = new Mock <IUowData>();
            var threadRepository = new Mock <IRepository <Thread> >();
            var mappingService   = new Mock <IMappingService>();

            data.Setup(d => d.Threads).Returns(threadRepository.Object);

            var claim = new Claim("test", "asd-123");

            var identity = new Mock <ClaimsIdentity>();

            identity.Setup(i => i.FindFirst(It.IsAny <string>())).Returns(claim);

            var principal = new Mock <IPrincipal>();

            principal.Setup(p => p.Identity).Returns(identity.Object);

            var context = new Mock <ControllerContext>();

            context.Setup(c => c.HttpContext.User).Returns(principal.Object);

            mappingService.Setup(m => m.Map <Thread>(It.IsAny <CreateThreadViewModel>())).Returns(new Thread()
            {
                Id = 3
            });

            CreateController controller = new CreateController(data.Object, mappingService.Object)
            {
                ControllerContext = context.Object
            };

            var thread = new CreateThreadViewModel();

            //Act
            RedirectToRouteResult redirectResult = controller.Index(thread) as RedirectToRouteResult;

            //Assert
            Assert.AreEqual(3, redirectResult.RouteValues["id"]);
        }
        public void Forum_CreateController_Index_Post_ShouldAddInstanceOfAThread()
        {
            //Arrange
            var data           = new Mock <IUowData>();
            var mappingService = new Mock <IMappingService>();

            var threadRepository = new Mock <IRepository <Thread> >();

            data.Setup(d => d.Threads).Returns(threadRepository.Object);

            var claim = new Claim("test", "asd-123");

            var identity = new Mock <ClaimsIdentity>();

            identity.Setup(i => i.FindFirst(It.IsAny <string>())).Returns(claim);

            var principal = new Mock <IPrincipal>();

            principal.Setup(p => p.Identity).Returns(identity.Object);

            var context = new Mock <ControllerContext>();

            context.Setup(c => c.HttpContext.User).Returns(principal.Object);

            mappingService.Setup(m => m.Map <Thread>(It.IsAny <CreateThreadViewModel>())).Returns(new Thread());

            CreateController controller = new CreateController(data.Object, mappingService.Object)
            {
                ControllerContext = context.Object
            };

            var thread = new CreateThreadViewModel();

            //Act
            var result = controller.Index(thread) as ViewResult;

            //Assert
            threadRepository.Verify(d => d.Add(It.IsAny <Thread>()));
        }
예제 #21
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            System.Windows.Forms.Button allBtn = (System.Windows.Forms.Button)sender;
            if (allBtn.Text.Equals("全部执行"))
            {
                allBtn.Enabled = false;
                //点击了全部执行按钮,便禁用单条执行按钮
                overTurnBtnState(false);
                allBtn.Text = "停止";
                //开始执行线程

                List <QuestionaireEntity> questionList = QuestionaireData.result;

                foreach (var q in questionList)
                {
                    //设置终止线程状态为false
                    q.CloseThread = false;
                    //先判断线程集合中是否有这个线程
                    if (CreateController.threadDict.ContainsKey(q.SeriaNum))
                    {
                        //已经有此线程执行了,直接跳过
                        continue;
                    }
                    //新建刷题线程
                    Thread thread = new Thread(() => CreateController.exercise(this, q));
                    //加入到线程集合中
                    CreateController.threadDict.Add(q.SeriaNum, thread);
                    thread.Name = q.SeriaNum;
                    //启动线程
                    thread.Start();
                }
                allBtn.Enabled = true;
            }
            else
            {
                List <QuestionaireEntity> questionList = QuestionaireData.result;
                foreach (var q in questionList)
                {
                    //设置终止线程状态为false
                    q.CloseThread = true;
                }
                allBtn.Text = "正在停止...";

                /**
                 * allBtn.Enabled = false;
                 * //点击了停止 按钮,便停止刷单
                 * overTurnBtnState(true);
                 * allBtn.Text = "全部执行";
                 * //关闭所有的线程
                 * Dictionary<string, Thread>.ValueCollection threads = CreateController.threadDict.Values;
                 * foreach (var th in threads)
                 * {
                 *  th.Abort();
                 *  while (th.ThreadState != ThreadState.Aborted)
                 *  {
                 *      //当调用Abort方法后,如果thread线程的状态不为Aborted,主线程就一直在这里做循环,直到thread线程的状态变为Aborted为止
                 *      Thread.Sleep(100);
                 *  }
                 *
                 * }
                 **/
            }
        }
예제 #22
0
 private void Awake()
 {
     cc = this;
 }
예제 #23
0
 void goToSceneStore()
 {
     CreateController.shareCreate().createScene(this.nameScene);
     Destroy(this.gameObject);
 }
예제 #24
0
 public static void noMoney()
 {
     CreateController.shareCreate().createWarningCoin();
 }
        public void CallAlbumServiceGetAlbumsOnce_WhenInvoked()
        {
            // Arrange
            var createService = new Mock <ICreationService>();
            var artistService = new Mock <IArtistService>();
            var albumService  = new Mock <IAlbumService>();
            var genreService  = new Mock <IGenreService>();

            var id     = Guid.NewGuid();
            var artist = new Artist()
            {
                Name = "Artist Name"
            };
            var album = new Album()
            {
                Title = "Album Title"
            };
            var genre = new Genre()
            {
                Name = "Genre Name"
            };
            var genres = new List <Genre>()
            {
                new Genre()
                {
                    Name = "Genre Name"
                }
            };

            var songCollection = new List <Song>()
            {
                new Song()
                {
                    Id       = id,
                    Title    = "Song Title",
                    Album    = album,
                    Artist   = artist,
                    Duration = 5,
                    Genres   = genres,
                    Lyrics   = "Some Lyrics",
                    VideoUrl = "VideoUrl"
                }
            };

            var artistCollection = new List <Artist>()
            {
                artist
            };

            var albumCollection = new List <Album>()
            {
                album
            };

            var genreCollection = new List <Genre>()
            {
                genre
            };

            genreService.Setup(x => x.GetGenres()).Returns(() => genreCollection.AsQueryable());
            albumService.Setup(x => x.GetAlbums()).Returns(() => albumCollection.AsQueryable());
            artistService.Setup(x => x.GetArtists()).Returns(() => artistCollection.AsQueryable());

            var sut = new CreateController(
                createService.Object,
                artistService.Object,
                albumService.Object,
                genreService.Object);

            // Act
            sut.CreateSong();

            // Assert
            albumService.Verify(x => x.GetAlbums(), Times.Once);
        }
예제 #26
0
 public ProductServiceCreateTest()
 {
     this.controller = new CreateController();
 }