Esempio n. 1
0
        public async Task Can_Edit_Document_From_Template_MetaData()
        {
            var dbContextOptions = CreateNewContextOptions();
            var user             = await CreateUser(dbContextOptions);

            await CreateTemplate(dbContextOptions, user.Id);

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var service = new DocumentsService(context);
                var items   = new Dictionary <int, string> {
                    [0] = "Item 3", [1] = "Item 4"
                };

                await service.EditDocument(1, user.Id, items);

                await context.SaveChangesAsync();
            }

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var states = await context.DocumentStates.ToListAsync();

                Assert.Equal(2, states.Count);

                var oldState = states.First();
                var newState = states.Last();

                Assert.NotEqual(oldState.IdDocumentData, newState.IdDocumentData);
            }
        }
Esempio n. 2
0
        public async Task Can_Edit_Document_Change_Status_To_Final_Revizuit()
        {
            var dbContextOptions = CreateNewContextOptions();

            var user = await CreateUser(dbContextOptions);

            var user2 = await CreateUser(dbContextOptions);

            await CreateTemplate(dbContextOptions, user.Id);

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var document = await context.Documents.FirstAsync();

                document.DocumentTask = new DocumentTask {
                    UserId = user.Id
                };
                await context.SaveChangesAsync();
            }

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var service = new DocumentsService(context);
                var items   = new Dictionary <int, string> {
                    [0] = "Item 3", [1] = "Item 4"
                };

                await service.EditDocument(1, user2.Id, items);

                await context.SaveChangesAsync();
            }

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var lastState = await context.DocumentStates.LastAsync();

                Assert.Equal(DocumentStatus.FinalRevizuit, lastState.DocumentStatus);
            }
        }