Exemplo n.º 1
0
        public void SetProject_WithProject_ExpectedValuesAndPropertyChangedEventsFired()
        {
            // Setup
            var mocks   = new MockRepository();
            var project = mocks.Stub <IProject>();

            mocks.ReplayAll();

            project.Name        = "Test";
            project.Description = "Test description";

            var viewModel = new InfoViewModel();

            var propertyNames = new List <string>();

            viewModel.PropertyChanged += (sender, args) =>
            {
                propertyNames.Add(args.PropertyName);
            };

            // Call
            viewModel.SetProject(project);

            // Assert
            Assert.AreEqual(project.Name, viewModel.ProjectName);
            Assert.AreEqual(project.Description, viewModel.ProjectDescription);
            Assert.IsTrue(viewModel.ProjectDescriptionEditable);
            CollectionAssert.AreEqual(new[]
            {
                nameof(viewModel.ProjectName),
                nameof(viewModel.ProjectDescription),
                nameof(viewModel.ProjectDescriptionEditable)
            }, propertyNames);
            mocks.VerifyAll();
        }
Exemplo n.º 2
0
        public void GivenViewModelWithProject_WhenSettingProjectDescription_ThenExpectedValueAndPropertyChangedEventFired()
        {
            // Given
            const string description = "new description";

            var mocks   = new MockRepository();
            var project = mocks.Stub <IProject>();

            mocks.ReplayAll();

            var viewModel = new InfoViewModel();

            viewModel.SetProject(project);

            var propertyNames = new List <string>();

            viewModel.PropertyChanged += (sender, args) =>
            {
                propertyNames.Add(args.PropertyName);
            };

            // When
            viewModel.ProjectDescription = description;

            // Then
            Assert.AreEqual(description, viewModel.ProjectDescription);
            CollectionAssert.AreEqual(new[]
            {
                nameof(viewModel.ProjectDescription)
            }, propertyNames);
            mocks.VerifyAll();
        }
Exemplo n.º 3
0
        public void SetProject_ProjectNull_ExpectedValuesAndPropertyChangedEventsFired()
        {
            // Setup
            var viewModel = new InfoViewModel();

            var propertyNames = new List <string>();

            viewModel.PropertyChanged += (sender, args) =>
            {
                propertyNames.Add(args.PropertyName);
            };

            // Call
            viewModel.SetProject(null);

            // Assert
            Assert.IsNull(viewModel.ProjectName);
            Assert.IsNull(viewModel.ProjectDescription);
            Assert.IsFalse(viewModel.ProjectDescriptionEditable);
            CollectionAssert.AreEqual(new[]
            {
                nameof(viewModel.ProjectName),
                nameof(viewModel.ProjectDescription),
                nameof(viewModel.ProjectDescriptionEditable)
            }, propertyNames);
        }