|
using System.ComponentModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SchoolSample.Common;
using SchoolSample.ViewModel;
namespace Test.SchoolSample.ViewModel
{
/// <summary>
///This is a test class for MainPageViewModelTest and is intended
///to contain all MainPageViewModelTest Unit Tests
///</summary>
[TestClass]
public class MainPageViewModelTest
{
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
/// <summary>
///A test for MainPageViewModel Constructor
///</summary>
[TestMethod]
public void MainPageViewModelConstructorTest()
{
var mock = new Mock<ISchoolModel>();
mock.Setup(n => n.IsBusy).Returns(true);
MainPageViewModel target = new MainPageViewModel(mock.Object);
Assert.IsTrue(target.IsBusy);
}
/// <summary>
///A test for _schoolModel_PropertyChanged
///</summary>
[TestMethod]
[DeploymentItem("SchoolSample.ViewModel.dll")]
public void _schoolModel_PropertyChangedTest()
{
var mock = new Mock<ISchoolModel>();
mock.Setup(n => n.IsBusy).Returns(true);
MainPageViewModel_Accessor target = new MainPageViewModel_Accessor(mock.Object);
Assert.IsTrue(target.IsBusy);
target._isBusy = false;
Assert.IsFalse(target.IsBusy);
PropertyChangedEventArgs e = new PropertyChangedEventArgs("IsBusy");
target._schoolModel_PropertyChanged(null, e);
Assert.IsTrue(target.IsBusy);
}
/// <summary>
///A test for IsBusy
///</summary>
[TestMethod]
[DeploymentItem("SchoolSample.ViewModel.dll")]
public void IsBusyTest()
{
var mock = new Mock<ISchoolModel>();
MainPageViewModel_Accessor target = new MainPageViewModel_Accessor(mock.Object);
const bool expected = false;
target.IsBusy = expected;
bool actual = target.IsBusy;
Assert.AreEqual(expected, actual);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Weidong has been an information system professional since 1990. He has a Master's degree in Computer Science, and is currently a MCSD .NET