Exemplo n.º 1
0
		public void ViewOrganisationTest()
		{
			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns(() => 
				new OperationResult<List<Organisation>>() 
				{ 
					Result = new List<Organisation> { new Organisation { Name = "Test" } } 
				});
			ClientManager.RubezhService = mock.Object;

			var organisationsViewModel = new OrganisationsViewModel();
			organisationsViewModel.Initialize(LogicalDeletationType.All);
			Assert.IsTrue(organisationsViewModel.Organisations.Count == 1);
			Assert.IsTrue(organisationsViewModel.SelectedOrganisation.Organisation.Name == "Test");
			Assert.IsTrue(organisationsViewModel.OrganisationDoorsViewModel.Items.Count == 0);
			Assert.IsTrue(organisationsViewModel.OrganisationUsersViewModel.Items.Count == 1);
			Assert.IsTrue(organisationsViewModel.OrganisationUsersViewModel.Items[0].IsChecked == false);
		}
Exemplo n.º 2
0
		public void AddOrganisationTest()
		{
			User.PermissionStrings.Add("Oper_SKD_Organisations_AddRemove");
			MockDialogService.OnShowModal += x =>
			{
				var organisationDetailsViewModel = x as OrganisationDetailsViewModel;
				organisationDetailsViewModel.Name = "Test";
				organisationDetailsViewModel.SaveCommand.Execute();

			};

			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns(() => new OperationResult<List<Organisation>>() { Result = new List<Organisation>() });
			mock.Setup(x => x.GetEmployeeList(It.IsAny<EmployeeFilter>())).Returns(() => new OperationResult<List<ShortEmployee>>() { Result = new List<ShortEmployee>() });
			mock.Setup(x => x.SaveOrganisation(It.IsAny<OrganisationDetails>(), It.IsAny<bool>())).Returns(() => new OperationResult<bool>() { Result = true });
			ClientManager.RubezhService = mock.Object;

			var organisationsViewModel = new OrganisationsViewModel();
			organisationsViewModel.Initialize(LogicalDeletationType.All);
			organisationsViewModel.AddCommand.Execute();
			Assert.IsTrue(organisationsViewModel.Organisations.Count == 1);
			Assert.IsTrue(organisationsViewModel.SelectedOrganisation.Organisation.Name == "Test");
		}
Exemplo n.º 3
0
		public void UnSetCurrentUserTest()
		{
			var user1 = new User{ Login = "******" };
			var user2 = new User{ Login = "******" };
			ClientManager.SecurityConfiguration.Users = new List<RubezhAPI.Models.User>{ user1, user2 };
			ClientManager._userLogin = "******";
			var organisation = new Organisation();
			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns<OrganisationFilter>(filter =>
			{
				return new OperationResult<List<Organisation>>(new List<Organisation> { organisation });
			});
			ClientManager.RubezhService = mock.Object;

			var organisationsViewModel = new OrganisationsViewModel();
			organisationsViewModel.Initialize(LogicalDeletationType.All);
			var organisationViewModel = organisationsViewModel.Organisations.FirstOrDefault();
			var currentUserViewModel = organisationsViewModel.OrganisationUsersViewModel.Items.FirstOrDefault(x => x.User.UID == ClientManager.CurrentUser.UID);
			Assert.IsFalse(currentUserViewModel.CanChange);
			var otherUserViewModel = organisationsViewModel.OrganisationUsersViewModel.Items.FirstOrDefault(x => x.User.UID != ClientManager.CurrentUser.UID);
			Assert.IsTrue(otherUserViewModel.CanChange);
		}