示例#1
0
        public void GetForEditShouldReturnTheCorrectData()
        {
            UserS.SeedPeshoAndGosho(this.context);
            var comps    = CompS.SeedTwoCompsToUser(this.context, UserS.GoshoId);
            var usedComp = comps[0];

            CompS.SeedThreeItemsToComp(this.context, usedComp);
        }
示例#2
0
        [Test]///Checked
        public void SaveShouldThrow_IfSomeOfToBeAlteredItems_HaveIdsNotInTheComparisonsItems()
        {
            UserS.SeedPeshoAndGosho(context);
            var comps    = CompS.SeedTwoCompsToUser(context, UserS.GoshoId);
            var usedComp = comps[0];
            var items    = CompS.SeedThreeItemsToComp(this.context, usedComp);

            var compSave = new ComparisonSave
            {
                Id             = usedComp.Id,
                Description    = null,
                Name           = null,
                TargetLanguage = null,
                SourceLanguage = null,
                AlteredItems   = new HashSet <ComparisonItemChange>
                {
                    new ComparisonItemChange
                    {
                        Id              = 1,
                        NewValue        = "new test value",
                        PropertyChanged = "Comment"
                    },
                    new ComparisonItemChange
                    {
                        Id              = 2,
                        NewValue        = "new test value",
                        PropertyChanged = "Order"
                    },
                    new ComparisonItemChange
                    {
                        Id              = 3,
                        NewValue        = "new test value",
                        PropertyChanged = "Source"
                    },
                    new ComparisonItemChange
                    {
                        Id              = 4,
                        NewValue        = "new test value",
                        PropertyChanged = "Target"
                    }
                }
            };

            ChangeTrackerOperations.DetachAll(this.context);
            Action action = () => this.comparisonService.Save(compSave, UserS.GoshoUsername);

            action.Should().Throw <AccessDenied>().WithMessage("The comparison items you are trying to alter does not belong the comparison you are altering!");
        }
示例#3
0
        [Test]///Checked
        public void SaveShouldAlterExistingItems_ForAValidRequest()
        {
            const string item1NewSource  = "itemOneNewSource";
            const string item1NewTarget  = "itemOneNewTarget";
            const string item1NewComment = "itemOneNewComment";
            const int    item1NewOrder   = 4;

            const string item2NewSource  = "itemTwoNewSource";
            const string item2NewTarget  = "itemTwoNewTarget";
            const string item2NewComment = "itemTwoNewComment";
            const int    item2NewOrder   = 3;


            UserS.SeedPeshoAndGosho(context);
            var comps    = CompS.SeedTwoCompsToUser(context, UserS.GoshoId);
            var usedComp = comps[0];
            var items    = CompS.SeedThreeItemsToComp(this.context, usedComp);

            var compSave = new ComparisonSave
            {
                Id             = usedComp.Id,
                Description    = null,
                Name           = null,
                TargetLanguage = null,
                SourceLanguage = null,
                AlteredItems   = new HashSet <ComparisonItemChange>
                {
                    new ComparisonItemChange
                    {
                        Id              = CompS.Item1Id,
                        NewValue        = item1NewComment,
                        PropertyChanged = "Comment"
                    },
                    new ComparisonItemChange
                    {
                        Id              = CompS.Item1Id,
                        NewValue        = item1NewOrder.ToString(),
                        PropertyChanged = "Order"
                    },
                    new ComparisonItemChange
                    {
                        Id              = CompS.Item1Id,
                        NewValue        = item1NewSource,
                        PropertyChanged = "Source"
                    },
                    new ComparisonItemChange
                    {
                        Id              = CompS.Item1Id,
                        NewValue        = item1NewTarget,
                        PropertyChanged = "Target"
                    },


                    new ComparisonItemChange
                    {
                        Id              = CompS.Item2Id,
                        NewValue        = item2NewComment,
                        PropertyChanged = "Comment"
                    },
                    new ComparisonItemChange
                    {
                        Id              = CompS.Item2Id,
                        NewValue        = item2NewOrder.ToString(),
                        PropertyChanged = "Order"
                    },
                    new ComparisonItemChange
                    {
                        Id              = CompS.Item2Id,
                        NewValue        = item2NewSource,
                        PropertyChanged = "Source"
                    },
                    new ComparisonItemChange
                    {
                        Id              = CompS.Item2Id,
                        NewValue        = item2NewTarget,
                        PropertyChanged = "Target"
                    },
                }
            };

            ChangeTrackerOperations.DetachAll(this.context);
            Action action = () => this.comparisonService.Save(compSave, UserS.GoshoUsername);

            action.Invoke();

            var item1 = context.ComparisonItems.SingleOrDefault(x => x.Id == CompS.Item1Id);
            var item2 = context.ComparisonItems.SingleOrDefault(x => x.Id == CompS.Item2Id);

            item1.Comment.Should().Be(item1NewComment);
            item1.Order.Should().Be(item1NewOrder);
            item1.Source.Should().Be(item1NewSource);
            item1.Target.Should().Be(item1NewTarget);

            item2.Comment.Should().Be(item2NewComment);
            item2.Order.Should().Be(item2NewOrder);
            item2.Source.Should().Be(item2NewSource);
            item2.Target.Should().Be(item2NewTarget);
        }