Ejemplo n.º 1
0
        public void TestTrainToBrowseTrainsViewModelHandleBooleanToStringAndDefaultEngineerName()
        {
            IxRepository repo = new CxTrainRepository();
            CxTrain train = repo.FindById<CxTrain>(4);

            CxBrowseTrainsViewModel viewModel = new CxBrowseTrainsViewModel();
            viewModel.InjectFrom(train)
                    .InjectFrom<BooleanToString>(train)
                    .InjectFrom<FromEngineerToSimpleStringName>(train);

            Assert.AreEqual(train.Id, viewModel.Id);
            Assert.AreEqual(train.Name, viewModel.Name);

            Assert.AreEqual(string.Format("{0}, {1}", train.DefaultEngineer.LastName, train.DefaultEngineer.FirstName), viewModel.DefaultEngineerName);
            Assert.AreEqual("Y", viewModel.IsAwake);
        }
Ejemplo n.º 2
0
        public void TestTrainToBrowseTrainsViewModelHandleBooleanToString()
        {
            IxRepository repo = new CxTrainRepository();
            CxTrain train = repo.FindById<CxTrain>(4);

            CxBrowseTrainsViewModel viewModel = new CxBrowseTrainsViewModel();
            viewModel.InjectFrom(train)
                    .InjectFrom<BooleanToString>(train);

            Assert.AreEqual(train.Id, viewModel.Id);
            Assert.AreEqual(train.Name, viewModel.Name);

            // Unlike AutoMapper ValueInject will Ignore mappings where property name and type do not match
            // no need to set Ignore
            //
            Assert.AreEqual("Y", viewModel.IsAwake);
        }