public PrintCharacterViewModel (int currentUserId, [NotNull] Character character, IReadOnlyCollection <PlotElement> plots) : base(character) { if (character == null) { throw new ArgumentNullException(nameof(character)); } CharacterDescription = character.Description.ToHtmlString(); var plotElements = character.GetOrderedPlots(character.SelectPlots(plots)).ToArray(); Plots = plotElements .ToViewModels(currentUserId, character) .ToArray(); Handouts = plotElements.Where(e => e.ElementType == PlotElementType.Handout) .Select(e => e.Texts.Content.ToPlainText()) .ToArray(); PlayerPhoneNumber = character.ApprovedClaim?.Player.Extra?.PhoneNumber; Fields = new CustomFieldsViewModel(currentUserId, character, disableEdit: true, onlyPlayerVisible: true, wherePrintEnabled: true); }
public void ShowPublicFieldToAnon() { var vm = new CustomFieldsViewModel(null, Mock.Character); var publicField = vm.FieldById(Mock.PublicField.ProjectFieldId); Assert.IsTrue(publicField?.CanView ?? true); Assert.IsNotNull(publicField?.Value); }
public void ShowPublicFieldToAnonEvenIfEditDisabled() { MockedProject.AssignFieldValues(Mock.Character, new FieldWithValue(Mock.PublicField, "1")); var vm = new CustomFieldsViewModel(currentUserId: null, character: Mock.Character, disableEdit: true); var publicField = vm.FieldById(Mock.PublicField.ProjectFieldId); publicField.ShouldNotBeNull(); publicField.CanView.ShouldBeTrue(); }
public void AllowCharactersFieldOnAddClaimForCharacterTest() { var vm = new CustomFieldsViewModel(Mock.Player.UserId, (IClaimSource)Mock.Character); var characterField = vm.FieldById(Mock.CharacterField.ProjectFieldId); Assert.IsNotNull(characterField); Assert.IsFalse(characterField.CanView); Assert.IsNull(characterField.Value); Assert.IsTrue(characterField.CanEdit); }
public void AllowCharactersFieldOnAddClaimTest() { var vm = new CustomFieldsViewModel(Mock.Player.UserId, (IClaimSource)Mock.Character); var characterField = vm.FieldById(Mock.CharacterField.ProjectFieldId); characterField.ShouldNotBeNull(); characterField.CanView.ShouldBeFalse(); characterField.Value.ShouldBeNull(); characterField.CanEdit.ShouldBeTrue(); }
public EditCharacterViewModel Fill(Character field, int currentUserId) { Navigation = CharacterNavigationViewModel.FromCharacter(field, CharacterNavigationPage.Editing, currentUserId); Fields = new CustomFieldsViewModel(currentUserId, field); ActiveClaimsCount = field.Claims.Count(claim => claim.IsActive); IsActive = field.IsActive; return(this); }
public void AllowCharactersFieldOnAddClaimForCharacterTest() { var vm = new CustomFieldsViewModel(Mock.Player.UserId, (IClaimSource)Mock.Character); var characterField = vm.Field(Mock.CharacterField); characterField.ShouldNotBeNull(); characterField.ShouldBeHidden(); characterField.ShouldNotHaveValue(); characterField.ShouldBeEditable(); }
public void AllowCharactersFieldOnAddClaimForGroupTest() { var vm = new CustomFieldsViewModel(Mock.Player.UserId, Mock.Group); var characterField = vm.FieldById(Mock.CharacterField.ProjectFieldId); characterField.ShouldNotBeNull(); characterField.ShouldBeHidden(); characterField.ShouldNotHaveValue(); characterField.ShouldBeEditable(); }
public CharacterDetailsViewModel(int?currentUserIdOrDefault, Character character, IEnumerable <PlotElement> plots) { Description = character.Description.ToHtmlString(); Player = character.ApprovedClaim?.Player; HasAccess = character.HasAnyAccess(currentUserIdOrDefault); ParentGroups = new CharacterParentGroupsViewModel(character, character.HasMasterAccess(currentUserIdOrDefault)); HidePlayer = character.HidePlayerForCharacter; Navigation = CharacterNavigationViewModel.FromCharacter(character, CharacterNavigationPage.Character, currentUserIdOrDefault); Fields = new CustomFieldsViewModel(currentUserIdOrDefault, character, disableEdit: true); Plot = plots.ToViewModels(currentUserIdOrDefault, character); }
public void DoNotDiscloseOriginalFieldValuesOnAddTest() { var mock = new MockedProject(); var vm = new CustomFieldsViewModel(mock.Player.UserId, (IClaimSource)mock.Character); var characterField = vm.Field(mock.CharacterField); characterField.ShouldNotBeNull(); characterField.ShouldBeHidden(); characterField.ShouldNotHaveValue(); characterField.ShouldBeEditable(); }
public void ProperlyShowConditionalHeaderTest() { var conditionalHeader = Mock.CreateConditionalHeader(); var claim = Mock.CreateApprovedClaim(Mock.Character, Mock.Player); var vm = new CustomFieldsViewModel(Mock.Player.UserId, claim); var characterField = vm.FieldById(conditionalHeader.ProjectFieldId); characterField.ShouldNotBeNull(); characterField.ShouldBeVisible(); characterField.ShouldNotHaveValue(); characterField.ShouldBeEditable(); }
public void ProperlyShowConditionalHeaderTest() { var mock = new MockedProject(); var claim = mock.CreateApprovedClaim(mock.Character, mock.Player); var vm = new CustomFieldsViewModel(mock.Player.UserId, claim); var characterField = vm.FieldById(mock.ConditionalHeader.ProjectFieldId); Assert.IsNotNull(characterField); Assert.IsTrue(characterField.CanView); Assert.IsNull(characterField.Value); Assert.IsTrue(characterField.CanEdit); }
public void ProperlyHideConditionalHeader() { var conditionalHeader = Mock.CreateConditionalHeader(); var claim = Mock.CreateApprovedClaim(Mock.CharacterWithoutGroup, Mock.Player); var vm = new CustomFieldsViewModel(Mock.Player.UserId, claim); var characterField = vm.FieldById(conditionalHeader.ProjectFieldId); characterField.ShouldNotBeNull(); characterField.ShouldBeHidden(); characterField.ShouldNotHaveValue(); characterField.ShouldBeReadonly(); }
public void DoNotDiscloseOriginalFieldValuesTest() { var mock = new MockedProject(); var claim = mock.CreateClaim(mock.Character, mock.Player); var vm = new CustomFieldsViewModel(mock.Player.UserId, claim); var characterField = vm.Field(mock.CharacterField); _ = characterField.ShouldNotBeNull(); characterField.ShouldBeHidden(); characterField.ShouldNotHaveValue(); characterField.ShouldBeEditable(); }
public void DoNotDiscloseOriginalFieldValuesTest() { var mock = new MockedProject(); var claim = mock.CreateClaim(mock.Character, mock.Player); var vm = new CustomFieldsViewModel(mock.Player.UserId, claim); var characterField = vm.FieldById(mock.CharacterField.ProjectFieldId); Assert.IsNotNull(characterField); Assert.IsFalse(characterField.CanView); Assert.IsNull(characterField.Value); Assert.IsTrue(characterField.CanEdit); }
public void AllowShadowCharacterFieldsTest() { var mock = new MockedProject(); var claim = mock.CreateClaim(mock.Character, mock.Player); MockedProject.AssignFieldValues(claim, new FieldWithValue(mock.CharacterField, "test")); var vm = new CustomFieldsViewModel(mock.Player.UserId, claim); var characterField = vm.FieldById(mock.CharacterField.ProjectFieldId); characterField.ShouldNotBeNull(); characterField.ShouldBeHidden(); characterField.Value.ShouldBe("test"); characterField.ShouldBeEditable(); }
public void Insert() { // Arrange - Create a new account view model var newCustomFieldsViewModel = new CustomFieldsViewModel() { OrganisationId = requiredOrganisationId, FieldType = 1 }; // Act - send this to the insert method on the account service logic var Response = _customFieldsService.Insert(newCustomFieldsViewModel, null); // Assert Assert.IsTrue(Response.Success); }
public void AllowShadowCharacterFieldsTest() { var mock = new MockedProject(); var claim = mock.CreateClaim(mock.Character, mock.Player); claim.JsonData = $"{{\"{mock.CharacterField.ProjectFieldId}\":\"test\"}}"; var vm = new CustomFieldsViewModel(mock.Player.UserId, claim); var characterField = vm.FieldById(mock.CharacterField.ProjectFieldId); Assert.IsNotNull(characterField); Assert.IsFalse(characterField.CanView); Assert.AreEqual("test", characterField.Value); Assert.IsTrue(characterField.CanEdit); }
public EditCharacterViewModel Fill(Character field, int currentUserId) { Navigation = CharacterNavigationViewModel.FromCharacter(field, CharacterNavigationPage.Editing, currentUserId); Fields = new CustomFieldsViewModel(currentUserId, field); ActiveClaimsCount = field.Claims.Count(claim => claim.IsActive); IsActive = field.IsActive; IsAcceptingClaimsEnabled = field.ApprovedClaim == null; IsAcceptingClaims = IsAcceptingClaims && IsAcceptingClaimsEnabled; CreatedAt = field.CreatedAt; UpdatedAt = field.UpdatedAt; CreatedBy = field.CreatedBy; UpdatedBy = field.UpdatedBy; return(this); }
public CharacterDetailsViewModel(int?currentUserIdOrDefault, Character character, IReadOnlyCollection <PlotElement> plots, IUriService uriService) { Player = character.ApprovedClaim?.Player; HasAccess = character.HasAnyAccess(currentUserIdOrDefault); ParentGroups = new CharacterParentGroupsViewModel(character, character.HasMasterAccess(currentUserIdOrDefault)); HidePlayer = character.HidePlayerForCharacter; Navigation = CharacterNavigationViewModel.FromCharacter(character, CharacterNavigationPage.Character, currentUserIdOrDefault); Fields = new CustomFieldsViewModel(currentUserIdOrDefault, character, disableEdit: true); Plot = PlotDisplayViewModel.Published(plots, currentUserIdOrDefault, character, uriService); HasMasterAccess = character.HasMasterAccess(currentUserIdOrDefault); CreatedAt = character.CreatedAt; UpdatedAt = character.UpdatedAt; CreatedBy = character.CreatedBy; UpdatedBy = character.UpdatedBy; }
public void PublicCharactersFieldValueOnAddClaimAreReadonlyIfNotShowForUnApprovedClaims() { var field = Mock.CreateField(new ProjectField() { IsPublic = true, CanPlayerEdit = true, ShowOnUnApprovedClaims = false }); var value = new FieldWithValue(field, "xxx"); Mock.Character.JsonData = new[] { value }.SerializeFields(); var vm = new CustomFieldsViewModel(Mock.Player.UserId, (IClaimSource)Mock.Character); var characterField = vm.Field(field); characterField.ShouldNotBeNull(); characterField.ShouldBeVisible(); characterField.Value.ShouldBe("xxx"); characterField.ShouldBeReadonly(); }
public CharacterListItemViewModel([NotNull] Character character, int currentUserId, IEnumerable <ClaimProblem> problems, IReadOnlyCollection <PlotElement> plots) { if (character == null) { throw new ArgumentNullException(nameof(character)); } if (character.ApprovedClaim != null) { BusyStatus = CharacterBusyStatusView.HasPlayer; ApprovedClaimId = character.ApprovedClaim.ClaimId; Player = character.ApprovedClaim.Player; } else if (character.Claims.Any(c => c.IsActive)) { BusyStatus = CharacterBusyStatusView.Discussed; } else if (character.IsAcceptingClaims) { BusyStatus = CharacterBusyStatusView.NotSend; } else { BusyStatus = CharacterBusyStatusView.Npc; } Name = character.CharacterName; CharacterId = character.CharacterId; ProjectId = character.ProjectId; Fields = new CustomFieldsViewModel(currentUserId, character, disableEdit: true); //This disable edit will speed up some requests. Problems = problems.Select(p => new ProblemViewModel(p)).ToList(); IndReadyPlotsCount = plots.Count(p => p.IsCompleted && p.TargetCharacters.Select(c => c.CharacterId).Contains(character.CharacterId)); IndAllPlotsCount = plots.Count(p => p.IsActive && p.TargetCharacters.Select(c => c.CharacterId).Contains(character.CharacterId)); ColReadyPlotsCount = plots.Count(p => p.IsCompleted && !p.TargetCharacters.Select(c => c.CharacterId).Contains(character.CharacterId)); ColAllPlotsCount = plots.Count(p => p.IsActive && !p.TargetCharacters.Select(c => c.CharacterId).Contains(character.CharacterId)); Groups = new CharacterParentGroupsViewModel(character, character.HasMasterAccess(currentUserId)); }
public PrintCharacterViewModel (int currentUserId, [NotNull] Character character, IReadOnlyCollection <PlotElement> plots, IUriService uriService) : base(character) { if (character == null) { throw new ArgumentNullException(nameof(character)); } var plotElements = character.GetOrderedPlots(character.SelectPlots(plots)).ToArray(); Plots = PlotDisplayViewModel.Published(plotElements, currentUserId, character, uriService); Handouts = plotElements.Where(e => e.ElementType == PlotElementType.Handout && e.IsActive) .Select(e => e.PublishedVersion()) .Where(e => e != null) .Select(e => new HandoutListItemViewModel(e.Content.ToPlainText(), e.AuthorUser)) .ToArray(); PlayerPhoneNumber = character.ApprovedClaim?.Player.Extra?.PhoneNumber; Fields = new CustomFieldsViewModel(currentUserId, character, disableEdit: true, onlyPlayerVisible: true, wherePrintEnabled: true); }
protected void FillFields(Character field, int currentUserId) { Fields = new CustomFieldsViewModel(currentUserId, field); }
protected void FillFields(Character field, int currentUserId) { Fields = new CustomFieldsViewModel(currentUserId, field); LegacyNameMode = field.Project.Details.CharacterNameLegacyMode; }
public void HideUnApprovedFieldOnAddClaimTest() { var vm = new CustomFieldsViewModel(Mock.Player.UserId, Mock.Group); (vm.FieldById(Mock.HideForUnApprovedClaim.ProjectFieldId)?.CanView ?? false).ShouldBeFalse(); }
public void HideMasterOnlyFieldOnAddClaimTest() { var vm = new CustomFieldsViewModel(Mock.Player.UserId, Mock.Group); (vm.FieldById(Mock.MasterOnlyField.ProjectFieldId)?.CanView ?? false).ShouldBeFalse(); }
public void ShowPublicFieldToAnonEvenIfEditDisabled() { var vm = new CustomFieldsViewModel(null, Mock.Character, disableEdit: true); Assert.IsTrue(vm.FieldById(Mock.PublicField.ProjectFieldId)?.CanView ?? true); }