Esempio n. 1
0
        public async Task AdditionalInfoDiff()
        {
            var db       = DbHelper.GetEmptyTestDB();
            var userName = RandomHelper.String();
            var userId   = await UserHelper.CreateInDbAsync(db, userName : userName);

            var originalVersionDate        = RandomHelper.Date();
            var originalAdditionInfo       = RandomHelper.String();
            var originalVersionDescription = RandomHelper.String();
            var language = await CardLanguagHelper.CreateAsync(db);

            var card = await CardHelper.CreateAsync(db, userId, originalVersionDate, additionalInfo : originalAdditionInfo, language : language, versionDescription : originalVersionDescription);

            var newAdditionalInfo     = RandomHelper.String();
            var newVersionDate        = RandomHelper.Date(originalVersionDate);
            var newVersionDescription = RandomHelper.String();

            using (var dbContext = new MemCheckDbContext(db))
                await new UpdateCard(dbContext.AsCallContext(), newVersionDate).RunAsync(UpdateCardHelper.RequestForAdditionalInfoChange(card, newAdditionalInfo, versionDescription: newVersionDescription));
            Guid previousVersionId;

            using (var dbContext = new MemCheckDbContext(db))
                previousVersionId = (await dbContext.CardPreviousVersions.Where(previous => previous.Card == card.Id).SingleAsync()).Id;
            using (var dbContext = new MemCheckDbContext(db))
            {
                var diffRequest = new GetCardDiff.Request(userId, card.Id, previousVersionId);
                var result      = await new GetCardDiff(dbContext.AsCallContext()).RunAsync(diffRequest);
                Assert.AreEqual(userName, result.CurrentVersionCreator);
                Assert.AreEqual(userName, result.OriginalVersionCreator);
                Assert.AreEqual(newVersionDate, result.CurrentVersionUtcDate);
                Assert.AreEqual(originalVersionDate, result.OriginalVersionUtcDate);
                Assert.AreEqual(newVersionDescription, result.CurrentVersionDescription);
                Assert.AreEqual(originalVersionDescription, result.OriginalVersionDescription);
                Assert.AreEqual(new(newAdditionalInfo, originalAdditionInfo), result.AdditionalInfo);
                Assert.IsNull(result.FrontSide);
                Assert.IsNull(result.BackSide);
                Assert.IsNull(result.Language);
                Assert.IsNull(result.Tags);
                Assert.IsNull(result.UsersWithView);
                Assert.IsNull(result.ImagesOnFrontSide);
                Assert.IsNull(result.ImagesOnBackSide);
                Assert.IsNull(result.ImagesOnAdditionalSide);
            }
        }