Пример #1
0
 public void NotApprovedClaimFieldVisibilitysTest()
 {
     //Ensure that
     VerifyClaim(
         projectMock.CreateClaim(projectMock.Character, projectMock.Player), //when claim is not yet approved
         projectMock.Player,                                                 //then the user who created the claim can see only the fields below
         projectMock.PublicField);
 }
Пример #2
0
        public void DisableUnapprovedClaimToChangeCharacterTest()
        {
            _original  = new MockedProject();
            _generator = new MockedFieldDefaultValueGenerator();
            var mock  = new MockedProject();
            var claim = mock.CreateClaim(mock.Character, mock.Player);

            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                claim,
                new Dictionary <int, string>()
            {
                { mock.CharacterField.ProjectFieldId, "test" },
            },
                _generator);
            ShouldBeTestExtensions.ShouldBe(mock.Character.JsonData,
                                            _original.Character.JsonData,
                                            "Adding claim should not modify any character fields");
            mock.Character.Groups.Select(g => g.CharacterGroupId).ToList().ShouldBe(
                (IEnumerable <int>)_original.Character.Groups.Select(g => g.CharacterGroupId)
                .ToList(),
                "Adding claim should not modify any character groups");
            ShouldBeTestExtensions.ShouldBe(claim.JsonData,
                                            $"{{\"{mock.CharacterField.ProjectFieldId}\":\"test\"}}");
        }
Пример #3
0
        public void SaveOnAddTest()
        {
            _original  = new MockedProject();
            _generator = new MockedFieldDefaultValueGenerator();
            var mock  = new MockedProject();
            var claim = mock.CreateClaim(mock.Character, mock.Player);

            // ReSharper disable once MustUseReturnValue
            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                claim,
                new Dictionary <int, string>()
            {
                { mock.CharacterField.ProjectFieldId, "test" },
            },
                _generator);
            mock.Character.JsonData
            .ShouldBe(_original.Character.JsonData,
                      "Adding claim should not modify any character fields");

            mock.Character.Groups.Select(g => g.CharacterGroupId).ShouldBe(
                mock.Character.Groups.Select(g => g.CharacterGroupId),
                "Adding claim should not modify any character groups");

            claim.JsonData.ShouldBe($"{{\"{mock.CharacterField.ProjectFieldId}\":\"test\"}}");
        }
Пример #4
0
        public void TryToChangeMasterOnlyFieldOnAdd()
        {
            var mock = new MockedProject();

            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                mock.CreateClaim(mock.Character, mock.Player),
                new Dictionary <int, string>()
            {
                { mock.MasterOnlyField.ProjectFieldId, "test" }
            });
        }
Пример #5
0
        public void HiddenFieldChangeFailedTest()
        {
            var mock  = new MockedProject();
            var claim = mock.CreateClaim(mock.Group, mock.Player);

            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                claim,
                new Dictionary <int, string>()
            {
                { mock.HideForUnApprovedClaim.ProjectFieldId, "test" }
            });
        }
Пример #6
0
        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();
        }
Пример #7
0
        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);
        }
Пример #8
0
        public void TryToChangeMasterOnlyFieldOnAdd()
        {
            _original  = new MockedProject();
            _generator = new MockedFieldDefaultValueGenerator();
            var mock = new MockedProject();

            Should.Throw <NoAccessToProjectException>(() =>
                                                      FieldSaveHelper.SaveCharacterFields(
                                                          mock.Player.UserId,
                                                          mock.CreateClaim(mock.Character, mock.Player),
                                                          new Dictionary <int, string>()
            {
                { mock.MasterOnlyField.ProjectFieldId, "test" },
            },
                                                          _generator));
        }
Пример #9
0
        public void ConditionalFieldChangeTestForGroup()
        {
            var mock  = new MockedProject();
            var claim = mock.CreateClaim(mock.Group, mock.Player);

            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                claim,
                new Dictionary <int, string>()
            {
                { mock.ConditionalField.ProjectFieldId, "test" }
            });
            Assert.AreEqual($"{{\"{mock.ConditionalField.ProjectFieldId}\":\"test\"}}", claim.JsonData);
            Assert.AreEqual(_original.Character.JsonData, mock.Character.JsonData,
                            "Adding claim should not modify any character fields");
        }
Пример #10
0
        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();
        }
Пример #11
0
        public void HiddenFieldChangeFailedTest()
        {
            _original  = new MockedProject();
            _generator = new MockedFieldDefaultValueGenerator();
            var mock  = new MockedProject();
            var claim = mock.CreateClaim(mock.Group, mock.Player);

            Should.Throw <NoAccessToProjectException>(() =>
                                                      FieldSaveHelper.SaveCharacterFields(
                                                          mock.Player.UserId,
                                                          claim,
                                                          new Dictionary <int, string>()
            {
                { mock.HideForUnApprovedClaim.ProjectFieldId, "test" },
            },
                                                          _generator));
        }
Пример #12
0
        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);
        }
Пример #13
0
        public void ApprovedClaimChangeTest()
        {
            var mock  = new MockedProject();
            var claim = mock.CreateClaim(mock.Character, mock.Player);

            claim.ClaimStatus = Claim.Status.Approved;
            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                claim,
                new Dictionary <int, string>()
            {
                { mock.CharacterField.ProjectFieldId, "test" }
            });
            Assert.AreEqual(
                $"{{\"{mock.CharacterField.ProjectFieldId}\":\"test\",\"{mock.PublicField.ProjectFieldId}\":\"Public\"}}",
                mock.Character.JsonData);
            Assert.AreEqual("{}", claim.JsonData);
        }
Пример #14
0
        public void DisableUnapprovedClaimToChangeCharacterTest()
        {
            var mock  = new MockedProject();
            var claim = mock.CreateClaim(mock.Character, mock.Player);

            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                claim,
                new Dictionary <int, string>()
            {
                { mock.CharacterField.ProjectFieldId, "test" }
            });
            Assert.AreEqual(_original.Character.JsonData, mock.Character.JsonData, "Adding claim should not modify any character fields");
            CollectionAssert.AreEqual(
                _original.Character.Groups.Select(g => g.CharacterGroupId).ToList(),
                mock.Character.Groups.Select(g => g.CharacterGroupId).ToList(),
                "Adding claim should not modify any character groups");
            Assert.AreEqual($"{{\"{mock.CharacterField.ProjectFieldId}\":\"test\"}}", claim.JsonData);
        }
Пример #15
0
        public void SaveOnAddTest()
        {
            var mock  = new MockedProject();
            var claim = mock.CreateClaim(mock.Character, mock.Player);

            // ReSharper disable once MustUseReturnValue
            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                claim,
                new Dictionary <int, string>()
            {
                { mock.CharacterField.ProjectFieldId, "test" }
            },
                generator);
            Assert.AreEqual(_original.Character.JsonData, mock.Character.JsonData, "Adding claim should not modify any character fields");
            CollectionAssert.AreEqual(
                _original.Character.Groups.Select(g => g.CharacterGroupId).ToList(),
                mock.Character.Groups.Select(g => g.CharacterGroupId).ToList(),
                "Adding claim should not modify any character groups");
            Assert.AreEqual($"{{\"{mock.CharacterField.ProjectFieldId}\":\"test\"}}", claim.JsonData);
        }
Пример #16
0
        public void ConditionalFieldChangeTestForGroup()
        {
            _original  = new MockedProject();
            _generator = new MockedFieldDefaultValueGenerator();
            var mock             = new MockedProject();
            var claim            = mock.CreateClaim(mock.Group, mock.Player);
            var conditionalField = mock.CreateConditionalField();

            FieldSaveHelper.SaveCharacterFields(
                mock.Player.UserId,
                claim,
                new Dictionary <int, string>()
            {
                { conditionalField.ProjectFieldId, "test" },
            },
                _generator);
            ShouldBeTestExtensions.ShouldBe(claim.JsonData,
                                            $"{{\"{conditionalField.ProjectFieldId}\":\"test\"}}");
            ShouldBeTestExtensions.ShouldBe(mock.Character.JsonData,
                                            _original.Character.JsonData,
                                            "Adding claim should not modify any character fields");
        }