public async Task <check_list_sites> CreateCheckListSite(check_lists checklist, DateTime createdAt,
                                                                 sites site, DateTime updatedAt, int version, string workflowState, int microting_uid)
        {
            check_list_sites cls = new check_list_sites();

            cls.CheckList     = checklist;
            cls.CreatedAt     = createdAt;
            cls.Site          = site;
            cls.UpdatedAt     = updatedAt;
            cls.Version       = version;
            cls.WorkflowState = workflowState;
            cls.MicrotingUid  = microting_uid;
            await cls.Create(dbContext).ConfigureAwait(false);

//            DbContext.check_list_sites.Add(cls);
//            await dbContext.SaveChangesAsync().ConfigureAwait(false);
            return(cls);
        }
Пример #2
0
        public async Task CheckListSites_Create_DoesCreate()
        {
            //Arrange

            Random rnd = new Random();

            short shortMinValue = Int16.MinValue;
            short shortmaxValue = Int16.MaxValue;

            bool randomBool = rnd.Next(0, 2) > 0;

            sites site = new sites
            {
                Name         = Guid.NewGuid().ToString(),
                MicrotingUid = rnd.Next(1, 255)
            };
            await site.Create(dbContext).ConfigureAwait(false);

            check_lists checklist = new check_lists
            {
                Color               = Guid.NewGuid().ToString(),
                Custom              = Guid.NewGuid().ToString(),
                Description         = Guid.NewGuid().ToString(),
                Field1              = rnd.Next(1, 255),
                Field2              = rnd.Next(1, 255),
                Field4              = rnd.Next(1, 255),
                Field5              = rnd.Next(1, 255),
                Field6              = rnd.Next(1, 255),
                Field7              = rnd.Next(1, 255),
                Field8              = rnd.Next(1, 255),
                Field9              = rnd.Next(1, 255),
                Field10             = rnd.Next(1, 255),
                Label               = Guid.NewGuid().ToString(),
                Repeated            = rnd.Next(1, 255),
                ApprovalEnabled     = (short)rnd.Next(shortMinValue, shortmaxValue),
                CaseType            = Guid.NewGuid().ToString(),
                DisplayIndex        = rnd.Next(1, 255),
                DownloadEntities    = (short)rnd.Next(shortMinValue, shortmaxValue),
                FastNavigation      = (short)rnd.Next(shortMinValue, shortmaxValue),
                FolderName          = Guid.NewGuid().ToString(),
                ManualSync          = (short)rnd.Next(shortMinValue, shortmaxValue),
                MultiApproval       = (short)rnd.Next(shortMinValue, shortmaxValue),
                OriginalId          = Guid.NewGuid().ToString(),
                ReviewEnabled       = (short)rnd.Next(shortMinValue, shortmaxValue),
                DocxExportEnabled   = randomBool,
                DoneButtonEnabled   = (short)rnd.Next(shortMinValue, shortmaxValue),
                ExtraFieldsEnabled  = (short)rnd.Next(shortMinValue, shortmaxValue),
                JasperExportEnabled = randomBool,
                QuickSyncEnabled    = (short)rnd.Next(shortMinValue, shortmaxValue)
            };
            await checklist.Create(dbContext).ConfigureAwait(false);

            check_list_sites checkListSite = new check_list_sites
            {
                MicrotingUid = rnd.Next(1, 255),
                SiteId       = site.Id,
                CheckListId  = checklist.Id,
                LastCheckId  = rnd.Next(1, 255)
            };

            //Act

            await checkListSite.Create(dbContext).ConfigureAwait(false);

            List <check_list_sites>         checkListSites        = dbContext.check_list_sites.AsNoTracking().ToList();
            List <check_list_site_versions> checkListSitesVersion = dbContext.check_list_site_versions.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(checkListSites);
            Assert.NotNull(checkListSitesVersion);

            Assert.AreEqual(1, checkListSites.Count());
            Assert.AreEqual(1, checkListSitesVersion.Count());

            Assert.AreEqual(checkListSite.CreatedAt.ToString(), checkListSites[0].CreatedAt.ToString());
            Assert.AreEqual(checkListSite.Version, checkListSites[0].Version);
//            Assert.AreEqual(checkListSite.UpdatedAt.ToString(), checkListSites[0].UpdatedAt.ToString());
            Assert.AreEqual(Constants.WorkflowStates.Created, checkListSites[0].WorkflowState);
            Assert.AreEqual(checkListSite.Id, checkListSites[0].Id);
            Assert.AreEqual(checkListSite.MicrotingUid, checkListSites[0].MicrotingUid);
            Assert.AreEqual(checkListSite.SiteId, site.Id);
            Assert.AreEqual(checkListSite.CheckListId, checklist.Id);
            Assert.AreEqual(checkListSite.LastCheckId, checkListSites[0].LastCheckId);

            //Versions
            Assert.AreEqual(checkListSite.CreatedAt.ToString(), checkListSitesVersion[0].CreatedAt.ToString());
            Assert.AreEqual(checkListSite.Version, checkListSitesVersion[0].Version);
//            Assert.AreEqual(checkListSite.UpdatedAt.ToString(), checkListSitesVersion[0].UpdatedAt.ToString());
            Assert.AreEqual(checkListSite.WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(checkListSite.Id, checkListSitesVersion[0].Id);
            Assert.AreEqual(checkListSite.MicrotingUid, checkListSitesVersion[0].MicrotingUid);
            Assert.AreEqual(site.Id, checkListSitesVersion[0].SiteId);
            Assert.AreEqual(checklist.Id, checkListSitesVersion[0].CheckListId);
            Assert.AreEqual(checkListSite.LastCheckId, checkListSitesVersion[0].LastCheckId);
        }