public void VerifyParticipantRoleUpdate() { var vm = new ParticipantRoleDialogViewModel(this.participantRole, this.transaction, this.session.Object, true, ThingDialogKind.Update, null, this.clone); Assert.AreEqual(ParticipantAccessRightKind.NONE, vm.ParticipantPermission.First().AccessRight); vm.ParticipantPermission.First().AccessRight = ParticipantAccessRightKind.READ; vm.OkCommand.Execute(null); this.session.Verify(x => x.Write(It.IsAny <OperationContainer>())); CDPMessageBus.Current.SendObjectChangeEvent(this.participantRole, EventKind.Updated); Assert.AreEqual(ParticipantAccessRightKind.READ, vm.ParticipantPermission.First().AccessRight); }
public void VerifyThatAllParticipantPermissionsAreSet() { var vm = new ParticipantRoleDialogViewModel(this.participantRole, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, this.clone); Assert.AreEqual(this.participantRole.ParticipantPermission.Count, vm.ParticipantPermission.Count); var participantRoleWith10Permissions = this.participantRole.Clone(false); participantRoleWith10Permissions.ParticipantPermission.RemoveRange(9, this.participantRole.ParticipantPermission.Count - 10); Assert.AreEqual(10, participantRoleWith10Permissions.ParticipantPermission.Count); vm = new ParticipantRoleDialogViewModel(participantRoleWith10Permissions, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, this.clone); Assert.AreEqual(this.participantRole.ParticipantPermission.Count, vm.ParticipantPermission.Count); // Check that if the version is not supported the participant role doesn't have any ParticipantPermision this.session.Setup(x => x.IsVersionSupported(It.IsAny <Version>())).Returns(false); vm = new ParticipantRoleDialogViewModel(participantRoleWith10Permissions, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, this.clone); Assert.AreEqual(0, vm.ParticipantPermission.Count); }
public void Setup() { this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.serviceLocator = new Mock <IServiceLocator>(); var metadataProvider = new MetaDataProvider(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IMetaDataProvider>()).Returns(metadataProvider); this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, null); var person = new Person(Guid.NewGuid(), this.cache, null) { Container = this.siteDir }; this.session.Setup(x => x.ActivePerson).Returns(person); this.session.Setup(x => x.IsVersionSupported(It.IsAny <Version>())).Returns(true); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.participantRole = new ParticipantRole { Name = "Participant role", ShortName = "ParticipantParticipantRole" }; this.cache.TryAdd(new CacheKey(this.siteDir.Iid, null), new Lazy <Thing>(() => this.siteDir)); this.clone = this.siteDir.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.siteDir); this.transaction = new ThingTransaction(transactionContext, this.clone); var dal = new Mock <IDal>(); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); this.viewmodel = new ParticipantRoleDialogViewModel(this.participantRole, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, this.clone); }
public void VerifyThatDefaultConstructorDoesNotThrowException() { var participantRoleDialogViewModel = new ParticipantRoleDialogViewModel(); Assert.IsNotNull(participantRoleDialogViewModel); }