Exemplo n.º 1
0
        public TestComboListTypeDto GetTestGroupDto(TestGroups testGroup)
        {
            var dto = new TestComboListTypeDto();

            dto.Id   = testGroup.Id;
            dto.Name = testGroup.Name;

            return(dto);
        }
Exemplo n.º 2
0
        public void GetGroupUsers_GroupNotInDataSet_ReturnsEmptyList()
        {
            using (IConfigurationDataSetLoader <TestGroupsDataSet> loader =
                       new UnitTestTestGroupsDataSetLoader(new UnitTestResourceMonitor()))
            {
                CheckTestGroupsDataSetLoader(loader);
                TestGroups testGroups = new TestGroups(loader);

                Assert.False(testGroups.GetGroupUsers("GroupNotInTestGroups").Any(),
                             "Returns empty list when group is not in DataSet.");
            }
        }
 //custom body
 //equals trait
 //hash code trait
 //pretty print
 public override void Print(PrettyPrinter printer)
 {
     printer.Println("UnitTestLaunch (");
     using (printer.IndentCookie()) {
         printer.Print("testNames = "); TestNames.PrintEx(printer); printer.Println();
         printer.Print("testGroups = "); TestGroups.PrintEx(printer); printer.Println();
         printer.Print("testCategories = "); TestCategories.PrintEx(printer); printer.Println();
         printer.Print("testResult = "); _TestResult.PrintEx(printer); printer.Println();
         printer.Print("runResult = "); _RunResult.PrintEx(printer); printer.Println();
     }
     printer.Print(")");
 }
Exemplo n.º 4
0
        /// <summary>
        /// Add a test case
        /// </summary>
        /// <param name="testCase"></param>
        public void AddTestCase(TestCase testCase)
        {
            tests.Add(testCase);
            var module = testCase.ModuleName ?? "";

            if (!TestGroups.ContainsKey(module))
            {
                TestGroups[module] = new List <TestCase>();
            }

            TestGroups[module].Add(testCase);
        }
Exemplo n.º 5
0
        public void IsUserInGroups_InputInDifferentCasing_ReturnsCorrectResult()
        {
            using (IConfigurationDataSetLoader <TestGroupsDataSet> loader =
                       new UnitTestTestGroupsDataSetLoader(new UnitTestResourceMonitor()))
            {
                CheckTestGroupsDataSetLoader(loader);
                TestGroups testGroups = new TestGroups(loader);

                Assert.True(testGroups.IsUserInGroups("*****@*****.**", "aUTOMATION"),
                            "Expected IsUserInGroups search to be case insensitive");
            }
        }
        public TestGroups GetTestGroup(TestGroups testGroup, TestGroupDto testGroupDto)
        {
            testGroup.Id                 = testGroupDto.Id;
            testGroup.Name               = testGroupDto.Name;
            testGroup.Notes              = testGroupDto.Notes;
            testGroup.OrderNo            = testGroupDto.OrderNo;
            testGroup.ShowTitleInReports = testGroupDto?.ShowTitleInReports;
            testGroup.ModifiedBy         = testGroupDto?.ModifiedBy;
            testGroup.ModifiedDate       = DateTime.UtcNow;

            return(testGroup);
        }
Exemplo n.º 7
0
 public void IsDefault_GroupNamesDoNotContainDefault_ReturnsFalse()
 {
     using (IConfigurationDataSetLoader <TestGroupsDataSet> loader =
                new UnitTestTestGroupsDataSetLoader(new UnitTestResourceMonitor()))
     {
         CheckTestGroupsDataSetLoader(loader);
         TestGroups testGroups = new TestGroups(loader);
         Assert.False(testGroups.IsDefault("group1;group2;group3;"),
                      "IsDefault returns false if test groups do not contain default group.");
         Assert.False(testGroups.IsDefault("groupallgroup;allgroup;groupall;"),
                      "IsDefault returns false if test groups contain 'all' as substring.");
     }
 }
Exemplo n.º 8
0
        public void GetDeploymentIdGroups_IdNotInDataSet_ReturnsDefaultGroups()
        {
            using (IConfigurationDataSetLoader <TestGroupsDataSet> loader =
                       new UnitTestTestGroupsDataSetLoader(new UnitTestResourceMonitor()))
            {
                CheckTestGroupsDataSetLoader(loader);
                TestGroups testGroups = new TestGroups(loader);

                Assert.True(
                    testGroups.GetDeploymentIdGroups(DeploymentIdNotInDataSet).Intersect(loader.LoadedDataSet.DefaultGroups).Count() ==
                    loader.LoadedDataSet.DefaultGroups.Count(),
                    "Returns default access groups list when deploymentId is not in DataSet.");
            }
        }
        public TestGroupDto GetTestGroupDto(TestGroups testGroups)
        {
            var dto = new TestGroupDto();

            dto.Id                 = testGroups.Id;
            dto.Name               = testGroups.Name;
            dto.Notes              = testGroups.Notes;
            dto.OrderNo            = testGroups.OrderNo;
            dto.ShowTitleInReports = testGroups?.ShowTitleInReports;
            dto.ModifiedBy         = testGroups?.ModifiedBy;
            dto.ModifiedDate       = testGroups.ModifiedDate;

            return(dto);
        }
Exemplo n.º 10
0
        public void GetGroupUsers_GroupInDataSet_ReturnsUsers()
        {
            using (IConfigurationDataSetLoader <TestGroupsDataSet> loader =
                       new UnitTestTestGroupsDataSetLoader(new UnitTestResourceMonitor()))
            {
                CheckTestGroupsDataSetLoader(loader);
                TestGroups testGroups = new TestGroups(loader);

                List <string> groupUsers = testGroups.GetGroupUsers("Automation").ToList();
                Assert.True(groupUsers.Count == 2, "Returns 2 users for Automation group.");
                Assert.True(groupUsers.Contains("*****@*****.**"), "Group contains [email protected]");
                Assert.True(groupUsers.Contains("*****@*****.**"), "Group contains [email protected]");
            }
        }
Exemplo n.º 11
0
        public void GetDeploymentIdGroups_IdInDataSet_ReturnsExpectedGroups()
        {
            using (IConfigurationDataSetLoader <TestGroupsDataSet> loader =
                       new UnitTestTestGroupsDataSetLoader(new UnitTestResourceMonitor()))
            {
                CheckTestGroupsDataSetLoader(loader);
                TestGroups testGroups = new TestGroups(loader);

                List <string> userGroups = testGroups.GetDeploymentIdGroups(DeploymentId).ToList();
                Assert.Equal(3, userGroups.Count);
                Assert.True(userGroups.Contains("Test"), "Groups contain Test");
                Assert.True(userGroups.Contains("Probes"), "Groups contain Probes");
                Assert.True(userGroups.Contains("all"), "Groups contain group 'all'");
            }
        }
Exemplo n.º 12
0
 public void IsDefault_GroupNamesContainDefault_ReturnsTrue()
 {
     using (IConfigurationDataSetLoader <TestGroupsDataSet> loader =
                new UnitTestTestGroupsDataSetLoader(new UnitTestResourceMonitor()))
     {
         CheckTestGroupsDataSetLoader(loader);
         TestGroups testGroups = new TestGroups(loader);
         Assert.True(testGroups.IsDefault("all;group2;group3;"),
                     "IsDefault returns true if test groups contain default group in the beginning.");
         Assert.True(testGroups.IsDefault("group1;group2;all;"),
                     "IsDefault returns true if test groups contain default group in the end followed by delimiter.");
         Assert.True(testGroups.IsDefault("group1;group2;all"),
                     "IsDefault returns true if test groups contain default group in the end not followed by delimiter.");
         Assert.True(testGroups.IsDefault("group1;all;group3"),
                     "IsDefault returns true if test groups contain default group in the middle.");
     }
 }
Exemplo n.º 13
0
        public void GetUserGroups_TestGroupsDataSetIsNull_ReturnsEmptyListAndLogs()
        {
            FailOnErrors = false;

            using (IConfigurationDataSetLoader <TestGroupsDataSet> loader =
                       new UnitTestDataSetLoader <TestGroupsDataSet>(new LocalCache(), new UnitTestResourceMonitor()))
            {
                TestGroups testGroups = new TestGroups(loader);

                LoggedEvents.Clear();
                Assert.False(testGroups.GetUserGroups("*****@*****.**").Any(),
                             "Returns empty list if currently loaded TestGroupsDataSet is null");
                IEnumerable <LogEventArgs> events = LoggedEvents;

                Assert.NotNull(events);
                Assert.Equal(1, events.Count(e => e.Level == Levels.Error));
                Assert.Equal(1, events.Count(e => e.Level == Levels.Warning));
            }
        }
Exemplo n.º 14
0
        public async Task TakeGroup(Guid groupId)
        {
            TestGroupRepository testGroupRepo = new TestGroupRepository();
            var testGroupTask = testGroupRepo.GetByIdAsync(groupId);

            ApplicationUserRepository <Tester> userRepo = new ApplicationUserRepository <Tester>();
            var testerTask = userRepo.GetByUserNameAsync(User.Identity.Name);

            TestGroups testGroups = new TestGroups();

            testGroups.TestGroup = await testGroupTask;
            testGroups.Status    = GroupStatus.Takened;
            testGroups.Takened   = DateTime.Now;
            testGroups.Tester    = await testerTask;

            TestGroup       testGroup = await testGroupTask;
            TestsRepository testsRepo = new TestsRepository();

            foreach (var testCase in testGroup.TestCases)
            {
                if (!testsRepo.IsTestTakened(testCase, await testerTask))
                {
                    DataAccess.Model.Tests.Tests tests = new DataAccess.Model.Tests.Tests();
                    tests.Test    = testCase;
                    tests.Status  = TestsStatus.Takened;
                    tests.Takened = DateTime.Now;
                    tests.Tester  = await testerTask;

                    testsRepo.Create(tests);
                }
            }

            TestGroupsRepository testGroupsRepo = new TestGroupsRepository();

            testGroupsRepo.Create(testGroups);
        }
Exemplo n.º 15
0
        public async Task <ActionResult> Resolve(DataAccess.Model.Tests.Tests tests, HttpPostedFileBase[] files, Guid testGroupsGuid)
        {
            TestsRepository testsRepo = new TestsRepository();

            DataAccess.Model.Tests.Tests testsRecord = testsRepo.GetById(tests.Id);

            TestGroupsRepository testGroupsRepo = new TestGroupsRepository();
            TestGroups           testGroups     = testGroupsRepo.GetById(testGroupsGuid);

            TestStatusRepository testStatusRepo = new TestStatusRepository();

            ModelState.Remove("files");
            ModelState.Remove("testGroupsGuid");
            ModelState.Remove(nameof(DataAccess.Model.Tests.Tests.Tester));
            ModelState.Remove(nameof(DataAccess.Model.Tests.Tests.Status));
            ModelState.Remove(nameof(DataAccess.Model.Tests.Tests.Test));
            ModelState.Remove(nameof(DataAccess.Model.Tests.Tests.Evidences));
            ModelState.Remove(nameof(DataAccess.Model.Tests.Tests.Finished));
            ModelState.Remove(nameof(DataAccess.Model.Tests.Tests.Rejected));
            ModelState.Remove(nameof(DataAccess.Model.Tests.Tests.Takened));
            ModelState.Remove("TestStatus.Status");
            if (ModelState.IsValid)
            {
                if (testsRecord.Test.Creator.Credits < (int)Math.Ceiling(testsRecord.Test.Reward * testGroups.TestGroup.RewardMultiplier))
                {
                    ViewBag.TestStatus     = testStatusRepo.GetAll();
                    ViewBag.TestGroup      = testGroups.TestGroup.Name;
                    ViewBag.TestGroupsGuid = testGroups.Id;

                    TempData["error"] = "Createor of tests don't have required amount of coins. Please try resolve test later, or contact our support team.";
                    return(RedirectToAction("TakenedTestGroups"));
                }

                var testStatusTask = testStatusRepo.GetByIdAsync(tests.TestStatus.Id);

                IList <Evidence> evidences = new List <Evidence>();

                if (files[0] != null)
                {
                    var maxSizeInMb    = 20;
                    var byteSize       = 1048576;
                    var maxSizeInBytes = byteSize * maxSizeInMb;
                    foreach (var file in files)
                    {
                        if (file.ContentLength > maxSizeInBytes)
                        {
                            TempData["error"] = "File " + file.FileName + " is too big! (max size is " + maxSizeInMb + "MB)";

                            ViewBag.TestStatus     = testStatusRepo.GetAll();
                            ViewBag.TestGroup      = testGroups.TestGroup.Name;
                            ViewBag.TestGroupsGuid = testGroups.Id;
                            return(View("ResolveGroup", testsRecord));
                        }
                    }

                    foreach (var file in files)
                    {
                        Evidence evidence = new Evidence();
                        evidence.Id       = Guid.NewGuid();
                        evidence.Name     = evidence.Id.ToString();
                        evidence.RealName = Path.GetFileNameWithoutExtension(file.FileName);
                        evidence.Attached = DateTime.Now;

                        var extension = Path.GetExtension(file.FileName);
                        evidence.Extension = extension;

                        var path = Path.Combine(Server.MapPath($"~/Uploads/{testsRecord.Id}"), evidence.Name + extension);
                        Directory.CreateDirectory(Server.MapPath($"~/Uploads/{testsRecord.Id}"));
                        file.SaveAs(path);

                        evidences.Add(evidence);
                    }

                    testsRecord.Evidences = evidences;
                }

                testsRecord.TestStatus = await testStatusTask;
                testsRecord.Finished   = DateTime.Now;
                testsRecord.Status     = TestsStatus.Finished;

                testsRecord.Tester.Credits       = testsRecord.Tester.Credits + (int)Math.Ceiling(testsRecord.Test.Reward * testGroups.TestGroup.RewardMultiplier);
                testsRecord.Test.Creator.Credits = testsRecord.Test.Creator.Credits - (int)Math.Ceiling(testsRecord.Test.Reward * testGroups.TestGroup.RewardMultiplier);

                EvidenceRepository evidRepo = new EvidenceRepository();

                foreach (var evidence in evidences)
                {
                    evidRepo.Create(evidence);
                }

                testsRepo.Update(testsRecord);

                return(RedirectToAction("ResolveGroup", new { testGroupGuid = testGroups.Id }));
            }

            ViewBag.TestStatus     = testStatusRepo.GetAll();
            ViewBag.TestGroup      = testGroups.TestGroup.Name;
            ViewBag.TestGroupsGuid = testGroups.Id;

            return(View("ResolveGroup", testsRecord));
        }
Exemplo n.º 16
0
 public void InsertTestGroup(TestGroups testGroup)
 {
     testGroupsRepository.Insert(testGroup);
 }
Exemplo n.º 17
0
 public void UpdateTestGroup(TestGroups testGroup)
 {
     testGroupsRepository.Update(testGroup);
 }
Exemplo n.º 18
0
 public void TestNumberOfTestGroups()
 {
     Assert.AreEqual(1, TestGroups.Count());
 }