예제 #1
0
 public MainPage()
 {
     InitializeComponent();
     DataContext = new ViewModels.MainPageViewModel
     {
         Definition = "This is the initial state of the definition!",
         Word       = "Type a word for happy times!"
     };
 }
예제 #2
0
 public MainPage()
 {
     InitializeComponent();
     DataContext = new ViewModels.MainPageViewModel
                            {
                                Definition = "This is the initial state of the definition!",
                                Word = "Type a word for happy times!"
                            };
 }
        public void ShouldTellYouWhenAWordCannotBeFound()
        {
            //Arrange
            var mainPageViewModel = new MainPageViewModel
                                        {
                                            Word = "I do not exist",
                                            Definition = string.Empty,
                                            Service = new LocalLookupService()
                                        };

            //Act
            mainPageViewModel.Lookup.Execute(null);
            //Assert
            Assert.AreEqual(NotFoundText, mainPageViewModel.Definition);
        }
        public void ShouldRaiseAPropertyChangedEventWhenTheDefinitionIsChanged()
        {
            //Arrange
            var mainPageViewModel = new MainPageViewModel
            {
                Word = "word1",
                Definition = string.Empty
            };
            var eventRaised = false;
            mainPageViewModel.PropertyChanged += (sender, args) => eventRaised = true;

            //Act
            mainPageViewModel.Definition = "WOW, this is changing";

            //Assert
            Assert.That(eventRaised, "we expected the viewmodel to notify us that the data had changed.");
        }
        public void ShouldLookupWord()
        {
            //Arrange
            var mainPageViewModel = new MainPageViewModel
                                        {
                                            Word = "word1",
                                            Definition = string.Empty
                                        };
            mainPageViewModel.Service = new LocalLookupService();
            //Act
            mainPageViewModel.Lookup.Execute(null);

            var resultOfFirstLookup = mainPageViewModel.Definition;
            mainPageViewModel.Word = "word2";
            mainPageViewModel.Lookup.Execute(null);
            var resultOfSecondLookup = mainPageViewModel.Definition;

            //Assert
            Assert.IsNotNullOrEmpty(resultOfFirstLookup);
            Assert.AreNotEqual(resultOfFirstLookup, resultOfSecondLookup);
        }