private void GenerateBranch(BranchController parentBranch, out BranchController newBranch, out bool canBranchGenerateMore) { parentBranch.subBranches++; int newBranchGeneration = parentBranch.generation + 1; Transform head = parentBranch.transform.Find("Head"); Transform tail = parentBranch.transform.Find("Tail"); Quaternion rotation = Quaternion.Euler( parentBranch.transform.rotation.eulerAngles + Vector3.right * UnityEngine.Random.Range(-newBranchMaxRotation, newBranchMaxRotation) // TODO [-1 or 1] * Random(30, 70) + Vector3.forward * UnityEngine.Random.Range(-newBranchMaxRotation, newBranchMaxRotation) ); if (NoIntersections(head, tail, rotation * Vector3.up, newBranchGeneration)) { GameObject subBranch = Instantiate(branchPrefab, head.position, rotation); subBranch.transform.parent = parentBranch.transform; newBranch = subBranch.GetComponent <BranchController>(); newBranch.generation = newBranchGeneration; } else { newBranch = null; } canBranchGenerateMore = parentBranch.subBranches < subBranchesPerBranchLimit; }
private BranchController getParentBranchController() { Transform parent = transform.parent; BranchController parentBC = parent.GetComponent <BranchController>(); return(parentBC); }
public BranchControllerTest() { branchMock = new Mock <IBranch>(); loggerMock = new Mock <ILogger>(); iMasterDataMock = new Mock <IMasterData <BranchRequestModel, int> >(); branchController = new BranchController(iMasterDataMock.Object, loggerMock.Object, branchMock.Object); }
public async Task AddBranchTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var random = new Random().Next(1, 5000).ToString(); var requestModel = new BranchModel() { MainBranchAddress = new MainBranchAddressModel() { AddressName = "Riyadh", Address = "Riyadh", BranchAddressId = 1, Position = "Riyadh" }, CommittieeIds = new List <int>() { 1 }, BranchName = "Riyadh Branch" + random }; var response = await _branchController.AddBranch(requestModel); Assert.NotNull(response); Assert.Equal("Riyadh Branch" + random, response.BranchName); Assert.NotNull(response.MainBranchAddress); Assert.Equal("Riyadh", response.MainBranchAddress.Position); Assert.Equal("Riyadh", response.MainBranchAddress.Address); Assert.Equal("Riyadh", response.MainBranchAddress.AddressName); }
void addBranch() { int i = GameManager.instance.INFINITY_CYCLE_COUNT; while (i-- > 0) { BranchController lastBC = LastParent.GetComponent <BranchController>(); if (lastBC.hasFreeSlotsForChild()) { branchSize++; lastBC.addBranch(branchSize); return; } GameObject emptyNeigbour = lastBC.getEmptyNeighbourIfExists(); if (emptyNeigbour != null) { LastParent = emptyNeigbour; continue; } LastParent = lastBC.getFirstChildFromFirstNeighbour(); } throw new System.Exception("infinity cycle exception"); }
public void Setup() { mockBranchRepository = new Mock <IBranchRepository>(); //mockbranchcontroller = new BranchController(mockbranchcontroller.Object); branchController = new BranchController(mockBranchRepository.Object); }
public async Task RemoveAssignedUserTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); await _branchController.RemoveAssignedUser(15113, 4, 1); }
public async Task RemoveAssignedCommitteeTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var branchId = 3; var committeeId = 1; await _branchController.RemoveAssignedCommittee(committeeId, branchId); }
public void GetAllFilterByCurrent_Test() { // Arrange var mockService = new Mock <IBranchService>(); var controller = new BranchController(mockService.Object); // Act IQueryable <BranchModel> response = controller.GetAll(); Assert.AreEqual(response.Where(x => x.IsCurrent).Count(), response.Count()); }
public void Return_BranchDetailModel() { var mockBranchService = new Mock <ILibraryBranchService>(); mockBranchService.Setup(r => r.Get(888)).Returns(GetBranch()); var controller = new BranchController(mockBranchService.Object); var result = controller.Detail(888); var viewResult = result.Should().BeOfType <ViewResult>(); viewResult.Subject.Model.Should().BeOfType <BranchDetailModel>(); }
public async Task GetCommitteesNotAssignedToBranchTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var result = await _branchController.GetCommitteesNotAssignedToBranch(27); Assert.NotNull(result); Assert.NotEmpty(result); }
public void GetById_NotFound_Test() { // Arrange var mockService = new Mock <IBranchService>(); var controller = new BranchController(mockService.Object); // Act IHttpActionResult actionResult = controller.GetById(-1); // Assert Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); }
public void GetAll_Test() { // Arrange var mockService = new Mock <IBranchService>(); var controller = new BranchController(mockService.Object); // Act IQueryable <BranchModel> response = controller.GetAll(); // Assert Assert.IsNotNull(response); }
public void ReturnBranchDetailView() { var mockBranchService = new Mock <ILibraryBranch>(); mockBranchService.Setup(r => r.Get(888)).Returns(GetBranch()); var controller = new BranchController(mockBranchService.Object); var result = controller.Detail(888); Assert.IsType <ViewResult>(result); }
public async Task GetIDMUsersTest() { _claims = new Claim[2] { new Claim(ClaimTypes.Role, RoleNames.MonafasatAdmin), new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var response = await _branchController.GetIDMUsers(); Assert.NotNull(response); Assert.NotEmpty(response); }
public GameObject getEmptyNeighbourIfExists() { for (int i = 0; i < activeLayerMembers.Length; i++) { BranchController activeBC = activeLayerMembers[i].GetComponent <BranchController>(); if (activeBC.children.Count < GameManager.instance.CHILDREN_MAX_COUNT) { return(activeLayerMembers[i]); } } return(null); }
public void ReturnBranchIndexView() { var mockBranchService = new Mock <ILibraryBranch>(); mockBranchService.Setup(r => r.GetAll()).Returns(GetAllBranches()); //Arrange var controller = new BranchController(mockBranchService.Object); //Act var result = controller.Index(); Assert.IsType <ViewResult>(result); }
public void Should_Return_Type_BranchDetailModel() { var mockBranchService = new Mock <ILibraryBranch>(); var mockbranch = new Mock <IWebHostEnvironment>(); mockBranchService.Setup(r => r.GetById(678)).Returns(GetBranchById()); var controller = new BranchController(mockBranchService.Object, mockbranch.Object); var result = controller.Detail(678); var viewResult = result.Should().BeOfType <ViewResult>(); viewResult.Subject.Model.Should().BeOfType <branchDetailViewModel>(); }
public void Delete_Test() { // Arrange var mockService = new Mock <IBranchService>(); var controller = new BranchController(mockService.Object); int id = 10; int userId = 1; // Act IHttpActionResult actionResult = controller.Delete(id, userId); // Assert Assert.IsInstanceOfType(actionResult, typeof(OkResult)); }
public async Task GetBranchByAgencyTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var agencyCode = "022001000000"; var result = await _branchController.GetBranchByAgency(agencyCode); Assert.NotNull(result); Assert.NotEmpty(result); }
public void Return_Branch_Index_View() { var mockBranchService = new Mock <ILibraryBranchService>(); mockBranchService.Setup(r => r.GetAll()).Returns(GetAllBranches()); var controller = new BranchController(mockBranchService.Object); var result = controller.Index(); var viewResult = result.Should().BeOfType <ViewResult>(); var viewModel = viewResult.Subject.ViewData.Model.Should().BeAssignableTo <BranchIndexModel>(); viewModel.Subject.Branches.Count().Should().Be(3); }
public void IndexExceptionCase() { #region mockBranchRepository = new Mock <IBranchRepository>(); // Prepare the return data for GetAllQuotation() method. var branchList = new List <ViewBranches>(); branchList.Add(new ViewBranches { Branch_Id = 1, Branch_Name = "Theni" }); // Mock up the GetAllQuotation() repository method with expected return values. mockBranchRepository.Setup(m => m.GetAllUserBranch()).Returns(branchList); // Prepare the return data for the GetAddressList() method. var countrylist = new List <CountryList>(); countrylist.Add(new CountryList { ID = 1, Country_Name = "India" }); mockBranchRepository.Setup(m => m.GetAddresscountryList()).Returns(countrylist); var statelist = new List <StateList>(); statelist.Add(new StateList { ID = 1, State_Name = "Tamil Nadu" }); mockBranchRepository.Setup(m => m.GetAddressstateList()).Returns(statelist); var citylist = new List <CityList>(); citylist.Add(new CityList { ID = 1, City_Name = "Madurai" }); mockBranchRepository.Setup(m => m.GetAddresscityList()).Returns(citylist); branchController = new BranchController(mockBranchRepository.Object); #endregion // Now invoke the Index action. var actionResult = branchController.Index() as ViewResult; // Validate the expected result. ViewResult expectedResult = new ViewResult(); Assert.IsNotNull("Error", actionResult.ViewName); }
public async Task FindTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var requestModel = new BranchSearchCriteriaModel() { }; var response = await _branchController.Find(requestModel); Assert.NotNull(response); Assert.NotEmpty(response.Items); }
public void Return_Branch_Detail_View() { var mockBranchService = new Mock <ILibraryBranchService>(); mockBranchService.Setup(r => r.Get(888)).Returns(GetBranch()); var controller = new BranchController(mockBranchService.Object); var result = controller.Detail(888); var viewResult = result.Should().BeOfType <ViewResult>(); var viewModel = viewResult.Subject.ViewData.Model.Should().BeAssignableTo <BranchDetailModel>(); viewModel.Subject.Address.Should().Be("3 Commerce St"); viewModel.Subject.Telephone.Should().Be("123"); }
public async Task GetAssignedCommitteeByIdAndBranchTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var branchId = 3; var committeeId = 1; var result = await _branchController.GetAssignedCommitteeByIdAndBranch(committeeId, branchId); Assert.NotNull(result); Assert.Equal(1, result.CommitteeId); Assert.Equal(3, result.BranchId); }
public async Task AssignUsersBranchTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var requestModel = new BranchUserModel() { BranchId = 2644, UserName = "******", RoleName = RoleNames.MonafasatAdmin }; await _branchController.AssignUsersBranch(requestModel); }
public void Post_Test() { // Arrange var mockService = new Mock <IBranchService>(); var controller = new BranchController(mockService.Object); // Act IHttpActionResult actionResult = controller.Post(new BranchModel { Id = 10, Name = "Branch1" }, 1); var createdResult = actionResult as OkNegotiatedContentResult <int>; // Assert Assert.IsNotNull(createdResult); //Assert.AreEqual("DefaultApi", createdResult.RouteName); Assert.IsTrue(createdResult.Content >= 0); }
public async Task GetBranchCommitteesTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var requestModel = new BranchCommitteeSearchCriteriaModel() { BranchId = 4 }; var result = await _branchController.GetBranchCommittees(requestModel); Assert.NotNull(result); Assert.NotEmpty(result.Items); }
public async Task GetBranchUsersTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.Role, RoleNames.MonafasatAdmin) }; _branchController = _branchController.WithIdentity(_claims); var model = new BranchUserSearchCriteriaModel() { BranchId = 3 }; var response = await _branchController.GetBranchUsers(model); Assert.NotNull(response); Assert.NotEmpty(response.Items); }
public void Put_Test() { // Arrange var mockService = new Mock <IBranchService>(); var controller = new BranchController(mockService.Object); // Act IHttpActionResult actionResult = controller.Put(new BranchModel { Id = 10, Name = "Branch1" }, 1); var contentResult = actionResult as NegotiatedContentResult <BranchModel>; // Assert Assert.IsNotNull(contentResult); Assert.AreEqual(HttpStatusCode.Accepted, contentResult.StatusCode); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(10, contentResult.Content.Id); }
public ApplyContainerController() { _dbConnStr = DataProvider.GetConnectionString(); _docCtrl = new DocumentController(_dbConnStr); _branchCtrl = new BranchController(_dbConnStr); }
public AlarmRuleSetController() { _dbConnStr = DataProvider.GetConnectionString(); _docCtrl = new DocumentController(_dbConnStr); _branchCtrl = new BranchController(_dbConnStr); }