Esempio n. 1
0
            public void RandomizeReturnsTenUniqueItems()
            {
                var result  = sut.Randomize();
                var itemIds = result.Select(o => o.ItemId).Distinct();

                Assert.AreEqual(10, itemIds.Count());
            }
Esempio n. 2
0
        public void RandomizeTest()
        {
            List <Item>         items   = CreateItems();
            Testlet             testlet = new Testlet("A10", items);
            var                 test1   = testlet.Randomize();
            var                 test2   = testlet.Randomize();
            List <ItemTypeEnum> type    = test1.Select(x => x.ItemType).Take(2).Distinct().ToList();

            //Checks whether 2 lists are  not same and first 2 items are pretest only

            Assert.IsTrue(!test1.SequenceEqual(test2) && !type.Contains(ItemTypeEnum.Operational));
        }
Esempio n. 3
0
        public void FirstTwoPreTestItemCheck()
        {
            var preTestCount          = 0;
            List <ItemsItem> allitems = testlet.Randomize();

            do
            {
                if (allitems[0].ItemType.ToString() == "Pretest")
                {
                    preTestCount++;
                }
            }while (preTestCount < 2);
            Assert.AreEqual(2, preTestCount);
        }
Esempio n. 4
0
        public void TestWhenItemsListIsNull()
        {
            Testlet testlet = new Testlet("1", null);
            var     result  = testlet.Randomize();

            Assert.IsNull(result);
        }
Esempio n. 5
0
        public void Check_Testlet_4_Pretestof_10(Testlet testlet)
        {
            int pretestcnt = 4;
            //Act
            List <Item> items = testlet.Randomize().Where(x => x.ItemType == ItemTypeEnum.Pretest).ToList();

            //Assert
            Assert.AreEqual(pretestcnt, items.Count);
        }
Esempio n. 6
0
        public void Check_Testlet_setof_10(Testlet testlet) //Arrange
        {
            int totalitems = 10;
            //Act
            List <Item> items = testlet.Randomize();

            //Assert
            Assert.AreEqual(totalitems, items.Count);
        }
Esempio n. 7
0
        public void Assert_First_Two_Items_Are_Pretest()
        {
            var items   = LoadItems();
            var testlet = new Testlet("Testlet1", items);

            var firstTwoItems = testlet.Randomize().Take(2).ToList();

            Assert.IsTrue(firstTwoItems.All(x => x.ItemType == ItemTypeEnum.Pretest));
        }
Esempio n. 8
0
        public void Assert_Last_Eight_Items_Are_Pretest_and_Operational()
        {
            var items   = LoadItems();
            var testlet = new Testlet("Testlet2", items);

            var lastEightItems = testlet.Randomize().Skip(2).Take(8).ToList();

            Assert.IsTrue(lastEightItems.Any(x => x.ItemType == ItemTypeEnum.Operational));
            Assert.IsTrue(lastEightItems.Any(x => x.ItemType == ItemTypeEnum.Pretest));
        }
Esempio n. 9
0
        public void Assert_Items_are_Randomized()
        {
            var items   = LoadItems();
            var testlet = new Testlet("Testlet2", items);

            var availableItemIds = new List <string> {
                "1", "2", "3", "4"
            };

            LoopMethod(testlet, testlet.Randomize().Take(2).ToList(), availableItemIds);

            if (availableItemIds.Any())
            {
                testlet.Randomize();
                LoopMethod(testlet, testlet.Randomize().Take(2).ToList(), availableItemIds);
            }

            Assert.IsTrue(availableItemIds.Count == 0);
        }
Esempio n. 10
0
        public void Check_Testlet_6_Operationof_10(Testlet testlet)
        {
            int operationalcnt = 6;
            //Act
            List <Item> items = testlet.Randomize()
                                .Where(x => x.ItemType == ItemTypeEnum.Operational)
                                .ToList();

            //Assert
            Assert.AreEqual(operationalcnt, items.Count);
        }
Esempio n. 11
0
        public void Check_Testlet_first2_Pretestof_10(Testlet testlet)
        {
            //Act
            List <Item> items = testlet.Randomize();

            //Arrange
            bool firsttwopretest = items[0].ItemType == ItemTypeEnum.Pretest;

            firsttwopretest = firsttwopretest && items[1].ItemType == ItemTypeEnum.Pretest;

            //Assert
            Assert.IsTrue(firsttwopretest);
        }
Esempio n. 12
0
        public void TestMethod()
        {
            List <Item> Items = new List <Item>();

            Items.Add(new Item()
            {
                ItemId = "1", ItemType = ItemTypeEnum.Operational
            });
            Items.Add(new Item()
            {
                ItemId = "2", ItemType = ItemTypeEnum.Operational
            });
            Items.Add(new Item()
            {
                ItemId = "3", ItemType = ItemTypeEnum.Operational
            });
            Items.Add(new Item()
            {
                ItemId = "4", ItemType = ItemTypeEnum.Operational
            });
            Items.Add(new Item()
            {
                ItemId = "5", ItemType = ItemTypeEnum.Operational
            });
            Items.Add(new Item()
            {
                ItemId = "6", ItemType = ItemTypeEnum.Operational
            });
            Items.Add(new Item()
            {
                ItemId = "7", ItemType = ItemTypeEnum.Operational
            });
            Items.Add(new Item()
            {
                ItemId = "8", ItemType = ItemTypeEnum.Pretest
            });
            Items.Add(new Item()
            {
                ItemId = "9", ItemType = ItemTypeEnum.Pretest
            });
            Items.Add(new Item()
            {
                ItemId = "10", ItemType = ItemTypeEnum.Operational
            });

            Program _program = new Program();
            Testlet t        = new Testlet("1", Items);
            int     cnt      = t.Randomize().Where(g => g.ItemType.Equals(ItemTypeEnum.Pretest)).Take(2).Count();

            Assert.AreEqual(2, cnt);
        }
Esempio n. 13
0
        public void TestFirstTwoItemPretest_WhenPretestIsAtFirstPostion_InTheList()
        {
            List <Item> testLetItems = new List <Item>()
            {
                new Item {
                    ItemId = "1", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "2", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "3", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "4", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "5", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "6", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "7", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "8", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "9", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "10", ItemType = ItemTypeEnum.Operational
                },
            };
            Testlet testlet       = new Testlet("1", testLetItems);
            var     result        = testlet.Randomize();
            var     filterPretest = result?.Take(2).ToList();

            Assert.IsNotNull(filterPretest);
            Assert.IsTrue(filterPretest.Count == 2);
            Assert.IsTrue(filterPretest.All(x => x.ItemType == ItemTypeEnum.Pretest));
            Assert.IsTrue(testLetItems.All(x => result.Contains(x)));
            //Test Randomness
            var inputids  = string.Join(",", testLetItems.Select(x => x.ItemId));
            var resultids = string.Join(",", result.Select(x => x.ItemId));

            Assert.AreNotEqual(inputids, resultids);
            Assert.AreNotEqual(inputids, resultids);
        }
        public void TestQuestionsDuplicateCount()
        {
            TestQuestion testQuestion = new TestQuestion();

            Testlet testlet = new Testlet();

            //   testlet.TestletId = "1";
            testlet.SetQuestions = testQuestion.GetQuestions();
            List <Question> testletCollection = testlet.Randomize();

            Int32 duplicates = testletCollection.GroupBy(x => x.QuestionId).Where(g => g.Count() > 1).Count();

            Assert.AreEqual(duplicates, 0);
        }
Esempio n. 15
0
 private void LoopMethod(Testlet testlet, List <Item> firstTwoItems, List <string> availableItemIds)
 {
     foreach (var item in firstTwoItems)
     {
         if (availableItemIds.Contains(item.ItemId))
         {
             availableItemIds.Remove(item.ItemId);
         }
     }
     if (availableItemIds.Any())
     {
         LoopMethod(testlet, testlet.Randomize().Take(2).ToList(), availableItemIds);
     }
 }
        public void TestTotalCount()
        {
            TestQuestion testQuestion = new TestQuestion();

            Testlet testlet = new Testlet();

            //  testlet.TestletId = "1";
            testlet.SetQuestions = testQuestion.GetQuestions();
            List <Question> testletCollection = testlet.Randomize();

            Int32 questionsCount = testletCollection.Count;

            Assert.AreEqual(questionsCount, 10);
        }
Esempio n. 17
0
        public void AlgorithmIsCalled()
        {
            var testletMock = new Mock <IRandomizationAlgorithm>();
            var returnValue = new List <TestletItem>();

            testletMock
            .Setup(x => x.Randomize(It.IsAny <IReadOnlyList <TestletItem> >()))
            .Returns(returnValue);

            var testlet = new Testlet("test", new List <TestletItem>(), testletMock.Object);
            var result  = testlet.Randomize();

            Assert.Equal(returnValue, result);
            testletMock.Verify(x => x.Randomize(It.IsAny <IReadOnlyList <TestletItem> >()), Times.Once);
        }
        public void TestOperationalQuestionsCount()
        {
            TestQuestion testQuestion = new TestQuestion();

            Testlet testlet = new Testlet();

            //   testlet.TestletId = "1";

            testlet.SetQuestions = testQuestion.GetQuestions();
            List <Question> testletCollection = testlet.Randomize();

            Int32 operationalTypeCount = testletCollection.Where(x => x.ItemType == QuestionTypeEnum.Operational).ToList().Count();

            Assert.AreEqual(operationalTypeCount, 6);
        }
        public void TestPreTestQuestionsCount()
        {
            //Testlet -- Collection
            TestQuestion testQuestion = new TestQuestion();

            Testlet testlet = new Testlet();

            //  testlet.TestletId = "1";
            testlet.SetQuestions = testQuestion.GetQuestions();
            List <Question> testletCollection = testlet.Randomize();

            Int32 preTestTypeCount = testletCollection.FindAll(x => x.ItemType == QuestionTypeEnum.Pretest).Count;

            Assert.AreEqual(preTestTypeCount, 4);
        }
        public void Randomize_WhenOnlyOnePretestItem_ShouldReturnCorrectResultCollection()
        {
            var initialItems = new List <TestletItem>
            {
                new TestletItem {
                    ItemId = "item-pretest-1", ItemType = TestletItemType.Pretest
                }
            };

            var target = new Testlet(ValidTestletId, 1, initialItems);

            var result = target.Randomize();

            result.Should().BeEquivalentTo(initialItems);
        }
Esempio n. 21
0
 private void TestletForm_Load(object sender, EventArgs e)
 {
     try
     {
         Testlet testlet = new Testlet();
         Items = testlet.Randomize();
         LoadData();
         btnPrev.Enabled = false;
         btnSubmit.Hide();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 22
0
        static void Main()
        {
            List <Item> itemlist = new List <Item>(10)
            {
                new Item {
                    ItemId = "5", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "6", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "7", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "8", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "9", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "10", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "1", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "2", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "3", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "4", ItemType = ItemTypeEnum.Pretest
                }
            };
            Testlet t = new Testlet("1", itemlist);

            for (int i = 0; i < 5; i++)
            {
                itemlist = t.Randomize();

                itemlist.ForEach(x => Console.WriteLine(x.ItemId + "  " + x.ItemType));

                Console.WriteLine("--------------------");
                Console.WriteLine("Press Any Key for Next Testlet Set");
                Console.ReadLine();
            }
        }
Esempio n. 23
0
        public void TestForPreTestRandomSuccess()
        {
            List <Item> listItem = new List <Item>()
            {
                new Item {
                    ItemId = "1", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "2", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "3", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "4", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "5", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "6", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "7", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "8", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "9", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "10", ItemType = ItemTypeEnum.Operational
                }
            };

            var expectedList = new List <string> {
                "1", "2", "3", "4"
            };

            Testlet objTestlet = new Testlet("1", listItem);
            var     actualData = objTestlet.Randomize();

            Assert.IsTrue(expectedList.Contains(actualData[0].ItemId));
            Assert.IsTrue(expectedList.Contains(actualData[0].ItemId));
        }
Esempio n. 24
0
        public void TestWhenThereIs_PretestItemsNotExists_ShouldNotBreak()
        {
            List <Item> testLetItems = new List <Item>()
            {
                new Item {
                    ItemId = "5", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "6", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "7", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "1", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "2", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "3", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "4", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "8", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "9", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "10", ItemType = ItemTypeEnum.Operational
                },
            };
            Testlet testlet = new Testlet("1", testLetItems);
            var     result  = testlet.Randomize();

            Assert.IsTrue(testLetItems.All(x => result.Contains(x)));
            //Test Randomness
            var inputids  = string.Join(",", testLetItems.Select(x => x.ItemId));
            var resultids = string.Join(",", result.Select(x => x.ItemId));

            Assert.AreNotEqual(inputids, resultids);
        }
        public void Randomize_WhenValidParametersUsed_ShouldReturnNewCollectionWithFirstItemsAsPretest()
        {
            var target = new Testlet(ValidTestletId, ValidInitialPretestItemsCount, ValidTestletItemsCollection);

            var randomizedCollection = target.Randomize();

            randomizedCollection.Should().NotBeNull();

            randomizedCollection.Should().NotBeSameAs(ValidTestletItemsCollection);
            randomizedCollection.Should().BeEquivalentTo(ValidTestletItemsCollection);

            randomizedCollection
            .Take(ValidInitialPretestItemsCount)
            .Should().OnlyContain(item => item.ItemType == TestletItemType.Pretest, "The first items of new randomized collection always should be a pretest");

            randomizedCollection
            .Should().OnlyHaveUniqueItems(item => item.ItemId, "New randomized collection should not have any duplications");
        }
        static void Main(string[] args)
        {
            TestQuestion testQuestion = new TestQuestion();

            var quesCollection = testQuestion.GetQuestions();


            Testlet testlet = new Testlet();

            testlet.SetQuestions = quesCollection;
            var randomQuestions = testlet.Randomize();


            foreach (Question q in randomQuestions)
            {
                Console.WriteLine(q.QuestionId + " " + q.ItemType);
            }
            Console.ReadLine();
        }
        public void Randomize_WhenValidParametersUsed_ShouldReturnNewRandomizedCollection()
        {
            var target = new Testlet(ValidTestletId, ValidInitialPretestItemsCount, ValidTestletItemsCollection);

            var previousOrdering = new List <ICollection <string> >();

            for (int iterationId = 0; iterationId < 10; iterationId++)
            {
                var randomizedCollection = target.Randomize();

                randomizedCollection.Should().NotBeNull();

                var ordering = randomizedCollection.Select(item => item.ItemId).ToList();

                previousOrdering.Should().NotContain(ordering, "Each randomization should be unique.");

                previousOrdering.Add(ordering);
            }
        }
Esempio n. 28
0
        public void TestForPreTestRandomFromRemainingItemSucess()
        {
            List <Item> listItem = new List <Item>()
            {
                new Item {
                    ItemId = "1", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "2", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "3", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "4", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "5", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "6", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "7", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "8", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "9", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "10", ItemType = ItemTypeEnum.Operational
                }
            };

            Testlet objTestlet = new Testlet("1", listItem);
            var     actualData = objTestlet.Randomize();

            Assert.AreEqual(6, actualData.Where(x => x.ItemType == ItemTypeEnum.Operational).Count());
            Assert.AreEqual(actualData.Where(x => x.ItemType == ItemTypeEnum.Pretest).Count(), 4);
            Assert.AreEqual(10, actualData.Count);
        }
Esempio n. 29
0
        public void TestForPreTestFirstTwoItemFailure()
        {
            List <Item> listItem = new List <Item>()
            {
                new Item {
                    ItemId = "1", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "2", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "3", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "4", ItemType = ItemTypeEnum.Pretest
                },
                new Item {
                    ItemId = "5", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "6", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "7", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "8", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "9", ItemType = ItemTypeEnum.Operational
                },
                new Item {
                    ItemId = "10", ItemType = ItemTypeEnum.Operational
                }
            };

            Testlet objTestlet = new Testlet("1", listItem);
            var     actualData = objTestlet.Randomize();

            Assert.AreNotEqual(actualData[0].ItemType, ItemTypeEnum.Operational);
            Assert.AreNotEqual(actualData[1].ItemType, ItemTypeEnum.Operational);
        }
Esempio n. 30
0
            public void Setup()
            {
                var items = new List <Item>()
                {
                    new Item {
                        ItemId = "0", ItemType = ItemTypeEnum.Operational
                    },
                    new Item {
                        ItemId = "1", ItemType = ItemTypeEnum.Operational
                    },
                    new Item {
                        ItemId = "2", ItemType = ItemTypeEnum.Pretest
                    },
                    new Item {
                        ItemId = "3", ItemType = ItemTypeEnum.Pretest
                    },
                    new Item {
                        ItemId = "4", ItemType = ItemTypeEnum.Pretest
                    },
                    new Item {
                        ItemId = "5", ItemType = ItemTypeEnum.Pretest
                    },
                    new Item {
                        ItemId = "6", ItemType = ItemTypeEnum.Operational
                    },
                    new Item {
                        ItemId = "7", ItemType = ItemTypeEnum.Operational
                    },
                    new Item {
                        ItemId = "8", ItemType = ItemTypeEnum.Operational
                    },
                    new Item {
                        ItemId = "9", ItemType = ItemTypeEnum.Operational
                    }
                };

                sut    = new Testlet(string.Empty, items, new TestletRerverse());
                result = sut.Randomize();
            }