public void Fires_PropertyChange_Notification()
        {
            var viewModel = new UserDataViewModel();

            viewModel.AssertThatProperty(x => x.SelectedKeyValue).RaisesChangeNotification();
            viewModel.AssertThatProperty(x => x.CurrentLicense).RaisesChangeNotification();
        }
        public void Notifies_All_Screen_When_Selected_License_Changes()
        {
            var userData = new UserDataViewModel() as IUserDataViewModel;
            var licenseInfo = new LicenseInfoViewModel() as ILicenseInfoViewModel;

            var vm = new IssueLicenseViewModel(userData, licenseInfo);

            Assert.Same(vm.CurrentLicense, userData.CurrentLicense);
            Assert.Same(vm.CurrentLicense, licenseInfo.CurrentLicense);
        }
        public void Closing_ViewModel_Calls_TryClose_With_True_DialogResult()
        {
            var userData = new UserDataViewModel() as IUserDataViewModel;
            var licenseInfo = new LicenseInfoViewModel() as ILicenseInfoViewModel;

            var vm = new TestableIssueLicenseViewModel(userData, licenseInfo);
            vm.Accept();

            Assert.NotNull(vm.SelectedDialogResult);
            Assert.True(vm.SelectedDialogResult.Value);
        }
        public void Can_Remove_When_There_Is_A_Valid_Selection()
        {
            var viewModel = new UserDataViewModel();
            var defaultCanRemove = viewModel.CanRemoveSelected;
            
            viewModel.CurrentLicense = new License();
            viewModel.SelectedKeyValue = new UserData();

            var canRemove = viewModel.CanRemoveSelected;

            Assert.False(defaultCanRemove);
            Assert.True(canRemove);
        }
        public void Can_Accept_New_License_When_OwnerName_Is_Filled()
        {
            var userData = new UserDataViewModel() as IUserDataViewModel;
            var licenseInfo = new LicenseInfoViewModel() as ILicenseInfoViewModel;

            var vm = new TestableIssueLicenseViewModel(userData, licenseInfo);

            var defaultCanAccept = vm.CanAccept;
            vm.CurrentLicense.OwnerName = "John Doe";
            var canAccept = vm.CanAccept;

            Assert.False(defaultCanAccept);
            Assert.True(canAccept);
        }
        public void Can_AddKey_When_There_Is_A_Valid_Selection()
        {
            var viewModel = new UserDataViewModel();
            var defaultCanAdd = viewModel.CanAddKey;

            viewModel.CurrentLicense = new License();
            viewModel.CurrentKey = "UserKey";
            viewModel.CurrentValue = "UserValue";

            var canAdd = viewModel.CanAddKey;

            Assert.False(defaultCanAdd);
            Assert.True(canAdd);
        }
        public void RemoveSelected_Removes_UserData_From_License()
        {
            var viewModel = new UserDataViewModel();
            var license = new License();
            var data = new UserData();

            license.Data.Add(data);
            viewModel.CurrentLicense = license;
            viewModel.SelectedKeyValue = data;

            viewModel.RemoveSelected();

            Assert.DoesNotContain(data, viewModel.CurrentLicense.Data);
        }
        public void AddKey_Adds_To_Licese_UserData()
        {
            var viewModel = new UserDataViewModel();
            var license = new License();

            viewModel.CurrentLicense = license;
            viewModel.CurrentKey = "UserKey";
            viewModel.CurrentValue = "UserValue";
            
            viewModel.AddKey();

            var data = viewModel.CurrentLicense.Data[0];

            Assert.Equal("UserKey", data.Key);
            Assert.Equal("UserValue", data.Value);
        }