Beispiel #1
0
        public void CreateGroup()
        {
            var res = controller.Create();

            Assert.IsInstanceOfType(res, typeof(ViewResult));
            var viewRes = res as ViewResult;

            Assert.IsInstanceOfType(viewRes.Model, typeof(Group));
            //Assert.IsFalse(viewRes.ViewBag.Create);
        }
        public void CreateGroup(string gName, DateTime startDate, DateTime endDate)
        {
            Group           group = new Group(gName, startDate, endDate);
            GroupController gc    = new GroupController();

            gc.Create(group);
        }
Beispiel #3
0
        public async Task Validation_Fail_Model_GroupVisitor_GroupVisitorController()
        {
            var model = new CreateGroupModel();

            SimulateValidation(model);
            var result = (ViewResult)await groupController.Create(model);

            Assert.IsNotNull(result);

            var viewData = result.ViewData;
            var viewBag  = result.ViewBag;

            Assert.AreEqual(3, viewData.Values.Count);
            Assert.AreEqual(3, ((SelectList)viewBag.Genders).Count());
            Assert.AreEqual(4, ((SelectList)viewBag.CheckPoints).Count());
            Assert.AreEqual(5, ((SelectList)viewBag.Nationalities).Count());
        }
Beispiel #4
0
        public override async Task RunCommand(Player player, List <string> args)
        {
            if (args[0] == null)
            {
                return;
            }

            await GroupController.Create(await player.ToLastCharacter(), args[0]);
        }
Beispiel #5
0
        private Group CreateGroup(string name)
        {
            var group = new Group {
                Name = name,
            };

            _groupController.Create(group);

            return(group);
        }
Beispiel #6
0
        public void GetControlledOnlyReturnsController()
        {
            // Arrange
            var prefix = nameof(GetControlledOnlyReturnsController);

            var creator = _userController.Create(new User
            {
                Name = $"{prefix}_CreatorUser"
            });

            var group = _groupController.Create(new Group
            {
                Name = $"{prefix}_Group"
            }, creator.Id);

            var members = Enumerable.Range(0, 10).Select(i =>
            {
                var member = _userController.Create(new User
                {
                    Name = $"{prefix}_MemberUser_{i}"
                });

                _relationshipController.CreateRequest(new ActorRelationship
                {
                    AcceptorId  = group.Id,
                    RequestorId = member.Id
                }, true);

                return(member);
            }).ToList();

            // Act & Assert
            members.ForEach(m =>
            {
                var controlled = _groupController.GetControlled(m.Id);
                Assert.Empty(controlled);
            });

            var creatorControlled = _groupController.GetControlled(creator.Id);

            Assert.NotEmpty(creatorControlled);
            Assert.Equal(group.Id, creatorControlled[0].Id);
        }
        public void TestCreate()
        {
            var   groupController = new GroupController(testUserRepository, testGroupRepository);
            Group groupNewOne     = new Group();

            groupNewOne.Name = "Mike";
            groupNewOne.Id   = 1;
            var result = groupController.Create(groupNewOne) as RedirectToRouteResult;

            Assert.AreEqual("GetAll", result.RouteValues["action"]);
        }
        private Group CreateGroup(string name, int creatorId)
        {
            var group = new Group
            {
                Name = $"Group_{name}",
            };

            _groupController.Create(group, creatorId);

            return(group);
        }
        public void When_CreateGroup_Expect_GroupCreation()
        {
            var errorMessage    = string.Empty;
            var guid            = Guid.NewGuid().ToString();
            var newGroupCommand = new CreateGroupCommand()
            {
                Group = new Group()
                {
                    Name = guid, CurrentCapacity = 100M
                }
            };

            var actionResult = _groupController.Create(newGroupCommand);

            var createdGroup = ActionResultParser.ParseCreatedResult <Group>(actionResult, out errorMessage);

            CheckErrorMessage(errorMessage);

            Assert.AreNotEqual(0, createdGroup.Id);

            DeleteGroup(createdGroup);
        }
        public async Task Create_Group_ReturnsAViewResult_WithGroupModel()
        {
            DoGroupControllerInitialSetup();
            mockGroupServiceRepo.Setup(x => x.BuildGroupOwnerMember()).Returns(Task.FromResult(GetGroupAssignedModels()));

            // Act
            var result = await _groupController.Create();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <object>(viewResult.ViewData.Model) as GroupModel;

            Assert.True(string.IsNullOrEmpty(model.ObjectId));
        }
Beispiel #11
0
        public void CreateRequiredName()
        {
            // Arrange
            var controller = new GroupController(_service);

            // Act
            var groupToCreate = new Group();

            groupToCreate.Name = String.Empty;
            var result = (ViewResult)controller.Create(groupToCreate);

            // Assert
            var error = _modelState["Name"].Errors[0];

            Assert.AreEqual("Name is required.", error.ErrorMessage);
        }
Beispiel #12
0
        private async Task <GroupVisitorDTO> CreateGroup(CreateGroupModel group, params InfoVisitorModel[] visitor)
        {
            await accountController.SetInitDataAsync();

            group.Infoes = visitor;
            var result = (await groupController.Create(group)) as RedirectToRouteResult;

            if (result == null)
            {
                return(null);
            }

            var groupResult = groupService.GetAll().LastOrDefault();

            return(groupResult);
        }
        private Group CreateGroup()
        {
            var errorMessage    = string.Empty;
            var guid            = Guid.NewGuid().ToString();
            var newGroupCommand = new CreateGroupCommand()
            {
                Group = new Group()
                {
                    Name = guid, CurrentCapacity = 100M
                }
            };

            var actionResult = _groupController.Create(newGroupCommand);

            return(ActionResultParser.ParseCreatedResult <Group>(actionResult, out errorMessage));
        }
Beispiel #14
0
        public void Create()
        {
            // Arrange
            var controller = new GroupController(_service);

            // Act
            var groupToCreate = new Group();

            groupToCreate.Name = "Business";
            controller.Create(groupToCreate);

            // Assert
            var result = (ViewResult)controller.Index();
            var groups = (IEnumerable)result.ViewData.Model;

            CollectionAssert.Contains(groups.ToList(), groupToCreate);
        }
Beispiel #15
0
        public async Task TestCreate()
        {
            var groupAppService = Substitute.For <IGroupAppService>();

            groupAppService.CreateCustomAsync(Arg.Any <GroupInput>())
            .ReturnsForAnyArgs(Guid.NewGuid());

            var target = new GroupController(
                CreateMemoryCache(),
                CreateMapper(),
                Substitute.For <IDepartmentAppService>(),
                Substitute.For <IPositionAppService>(),
                groupAppService);

            target.ControllerContext = CreateMockContext();

            var result = await target.Create(new GroupEditVm
            {
                Name            = "aaa",
                AddingMemberIds = new HashSet <Guid> {
                    User_EmployeeMdmId, Guid.NewGuid()
                },
                AddingMemberNames = new List <string> {
                    User_EmployeeName, "李四"
                }
            });

            var createdResult = result.Result.As <CreatedAtActionResult>();

            createdResult.Should().NotBeNull();
            var data = createdResult.Value.As <ResponseData <Guid> >();

            data.Should().NotBe(Guid.Empty);

            await groupAppService.ReceivedWithAnyArgs().CreateCustomAsync(
                Arg.Is <GroupInput>(o => o.CurrentUserId == User_Id && o.CurrentEmployeeId == User_EmployeeMdmId));
        }
 public void ParticipantShouldCreateGroup()
 {
     _controller.Create(_participantHogent, "testGroup", false);
     Assert.Equal("testGroup", _participantHogent.Group.Name);
     Assert.False(_participantHogent.Group.Closed);
 }