Exemplo n.º 1
0
 public MainWindow()
 {
     try
     {
         InitializeComponent();
         DataContext = new DerDieDasViewModel(new CommandFactory(), new DerDieDasTest(new ResourceLoader("Tests")));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        public void Constructor_WhenSeveralToAdd_ThenSeveralAvailableTests()
        {
            //ARRANGE
            var mockedDerDieDasTest = new Mock<IDerDieDasTest>();
            var mockedCommandFactory = new Mock<ICommandFactory>();

            mockedDerDieDasTest.Setup(x => x.StartTest(It.IsAny<List<string>>()));
            mockedDerDieDasTest.Setup(x => x.AvailableTests).Returns(new List<string>{"Test1", "Test2", "Test3", "Test4"});

            //ACT
            var derDieDasViewModel = new DerDieDasViewModel(mockedCommandFactory.Object, mockedDerDieDasTest.Object);
            var allAvailableTestsCount = derDieDasViewModel.AllAvailableTests.Count;

            //ASSERT
            Assert.Equal(4, allAvailableTestsCount);
        }
        public void DerCheckedDasCheckedDieChecked_ThenSelectedArticleIsDie()
        {
            //ARRANGE
            var mockedDerDieDasTest = new Mock<IDerDieDasTest>();
            var mockedCommandFactory = new Mock<CommandFactory>(MockBehavior.Strict) { CallBase = true };
            var correctArticle = false;

            mockedDerDieDasTest.Setup(x => x.StartTest(It.IsAny<List<string>>()));
            mockedDerDieDasTest.Setup(x => x.AvailableTests).Returns(new List<string> { "Test1", "Test2", "Test3", "Test4" });
            mockedDerDieDasTest
                .Setup(x => x.Answer(It.Is<string>(y => y == new DieArticle().GetName()), It.IsAny<string>()))
                .Callback(() => correctArticle = true);

            //ACT
            var derDieDasViewModel = new DerDieDasViewModel(mockedCommandFactory.Object, mockedDerDieDasTest.Object);
            derDieDasViewModel.DerChecked = string.Empty;
            derDieDasViewModel.DasChecked = string.Empty;
            derDieDasViewModel.DieChecked = string.Empty;
            derDieDasViewModel.Submit.Execute(new object());

            //ASSERT
            Assert.True(correctArticle);
        }
        public void PercentagePluralComplete_WhenPercentageHasDecimalPlaces_ThenPrintsNoDecimalPlaces()
        {
            //ARRANGE
            var mockedDerDieDasTest = new Mock<IDerDieDasTest>();
            var mockedCommandFactory = new Mock<CommandFactory>(MockBehavior.Strict) { CallBase = true };
            mockedDerDieDasTest.Setup(x => x.PercentagePluralCorrect()).Returns(3.557);

            //ACT
            var derDieDasViewModel = new DerDieDasViewModel(mockedCommandFactory.Object, mockedDerDieDasTest.Object);
            var percentageComplete = derDieDasViewModel.PercentagePluralCorrect;

            //ASSERT
            Assert.Equal("4%", percentageComplete);
        }
        public void LoadAvailableTests_When0ToAdd_Then0AvailableTests()
        {
            //ARRANGE
            var mockedDerDieDasTest = new Mock<IDerDieDasTest>();
            var mockedCommandFactory = new Mock<ICommandFactory>();

            mockedDerDieDasTest.Setup(x => x.StartTest(It.IsAny<List<string>>()));
            mockedDerDieDasTest.Setup(x => x.AvailableTests).Returns(new List<string>());

            //ACT
            var derDieDasViewModel = new DerDieDasViewModel(mockedCommandFactory.Object, mockedDerDieDasTest.Object);
            derDieDasViewModel.LoadAvailableTests();

            //ASSERT
            Assert.Empty(derDieDasViewModel.AllAvailableTests);
        }