本文整理汇总了C#中TestViewModel类的典型用法代码示例。如果您正苦于以下问题:C# TestViewModel类的具体用法?C# TestViewModel怎么用?C# TestViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestViewModel类属于命名空间,在下文中一共展示了TestViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: should_load_the_user_from_the_id_on_the_principal
public void should_load_the_user_from_the_id_on_the_principal()
{
var model = new TestViewModel();
_behavior.PrepareInput(model);
_repo.AssertWasCalled(r => r.Load<User>(_userId));
}
示例2: TestPropertyChangedSend
public void TestPropertyChangedSend()
{
Messenger.Reset();
var receivedDateTimeMessengerOld = DateTime.MaxValue;
var receivedDateTimeMessengerNew = DateTime.MinValue;
var receivedDateTimeLocal = DateTime.MinValue;
Messenger.Default.Register<PropertyChangedMessage<DateTime>>(this, m =>
{
if (m.PropertyName == TestViewModel.LastChanged1PropertyName)
{
receivedDateTimeMessengerOld = m.OldValue;
receivedDateTimeMessengerNew = m.NewValue;
}
});
var vm = new TestViewModel();
vm.PropertyChanged += (s, e) =>
{
if (e.PropertyName == TestViewModel.LastChanged1PropertyName)
{
receivedDateTimeLocal = vm.LastChanged1;
}
};
var now = DateTime.Now;
vm.LastChanged1 = now;
Assert.AreEqual(now, vm.LastChanged1);
Assert.AreEqual(DateTime.MinValue, receivedDateTimeMessengerOld);
Assert.AreEqual(now, receivedDateTimeMessengerNew);
Assert.AreEqual(now, receivedDateTimeLocal);
}
示例3: ReturnsViewModelCommandManagerForViewModel
public void ReturnsViewModelCommandManagerForViewModel()
{
var viewModel = new TestViewModel();
var viewModelCommandManager = ViewModelCommandManager.Create(viewModel);
Assert.IsNotNull(viewModelCommandManager);
}
示例4: InitializeTest
public virtual void InitializeTest(TestViewModel viewModel) {
// This is called when a TestViewModel is created
viewModel.DoSomething.Action = this.DoSomethingHandler;
viewModel.DoSomethingElse.Action = this.DoSomethingElseHandler;
viewModel.CommandReference.Action = this.CommandReferenceHandler;
TestViewModelManager.Add(viewModel);
}
示例5: PropertyWithDataTypePasswordAttributeShouldHaveTheTypePassword
public void PropertyWithDataTypePasswordAttributeShouldHaveTheTypePassword()
{
var model = new TestViewModel();
var tag = MvcMockHelpers.GetHtmlHelper(model).Input(x => x.Password);
tag.TagName().ShouldBe("input");
tag.Attr("type").ShouldBe("password");
}
示例6: SetUp
public void SetUp()
{
viewModel = new TestViewModel()
{
Id = -10
};
}
示例7: ThrowsArgumentNullExceptionForNullHandler
public void ThrowsArgumentNullExceptionForNullHandler()
{
var viewModel = new TestViewModel();
var viewModelCommandManager = ViewModelCommandManager.Create(viewModel);
ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => viewModelCommandManager.AddHandler(null));
}
示例8: ExpressionEvaluator_UpdateSource_Simple
public void ExpressionEvaluator_UpdateSource_Simple()
{
var viewModel = new TestViewModel() { SubObject = new TestViewModel2() { Value = "hello" } };
var view = new RedwoodView()
{
DataContext = viewModel,
Children =
{
new HtmlGenericControl("html")
{
Children =
{
new TextBox()
{
ID = "txb"
}
.WithBinding(TextBox.TextProperty, new ValueBindingExpression("Value"))
}
}
.WithBinding(RedwoodBindableControl.DataContextProperty, new ValueBindingExpression("SubObject"))
}
};
var textbox = view.FindControl("txb") as TextBox;
var binding = textbox.GetBinding(TextBox.TextProperty) as ValueBindingExpression;
binding.UpdateSource("test", textbox, TextBox.TextProperty);
Assert.AreEqual("test", viewModel.SubObject.Value);
}
示例9: ViewModel_NavigationReturnsNavigation
public void ViewModel_NavigationReturnsNavigation()
{
var mockNav = Mock.Of<INavigation>();
Container.Current.RegisterInstance<INavigation>(mockNav);
var t = new TestViewModel();
Assert.That(t.Navigation, Is.Not.Null);
}
示例10: PropertyWithHiddenInputAttributeShouldMakeTheTypeHidden
public void PropertyWithHiddenInputAttributeShouldMakeTheTypeHidden()
{
var model = new TestViewModel();
var tag = MvcMockHelpers.GetHtmlHelper(model).Input(x => x.Hidden);
tag.TagName().ShouldBe("input");
tag.Attr("type").ShouldBe("hidden");
}
示例11: InputOfPropertyShouldBeCheckboxIfPropertyIsABool
public void InputOfPropertyShouldBeCheckboxIfPropertyIsABool()
{
var model = new TestViewModel();
var helper = MvcMockHelpers.GetHtmlHelper(model);
var tag = helper.Input(x => x.IsCorrect);
tag.Attr("type").ShouldBe("checkbox");
}
示例12: Can_Use_MerchelloContext_In_RazorEngine
public void Can_Use_MerchelloContext_In_RazorEngine()
{
//// Arrange
var model = new TestViewModel();
model.MerchelloContext = MerchelloContext.Current;
model.Product = _product.ToProductDisplay();
var template = @"
@{
var product = Model.MerchelloContext.Services.ProductService.GetByKey(Model.Product.Key);
}
<html>
<body>
<div>@Model.Product.Name, @Model.Product.Sku, @Model.Product.Price</div>
<ul>
@foreach(var option in Model.Product.ProductOptions)
{
<li>@option.Name</li>
}
</ul>
</body>
</html>";
//// Act
var result = Razor.Parse(template, model);
//// Assert
Assert.NotNull(result);
Assert.IsTrue(result.Contains("Color"));
}
示例13: TestDisableCommandAndRectangle
public void TestDisableCommandAndRectangle()
{
var trigger = new EventToCommand
{
MustToggleIsEnabledValue = true
};
var rectangle = new Rectangle();
((IAttachedObject)trigger).Attach(rectangle);
var vm = new TestViewModel();
var binding = new Binding
{
Source = vm.ToggledCommand
};
vm.EnableToggledCommand = false;
#if SILVERLIGHT3
trigger.Command = binding;
#else
BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
#endif
#if !SILVERLIGHT
Assert.IsFalse(rectangle.IsEnabled);
#endif
trigger.Invoke();
Assert.IsFalse(vm.CommandExecuted);
}
示例14: ExtenstionTest2
public void ExtenstionTest2() {
var service = new TestDialogService();
var viewModel = new TestViewModel();
var parentViewModel = new TestViewModel();
var commands = new List<UICommand>();
service = new TestDialogService();
service.ShowDialog(commands, "title1", viewModel);
Assert.AreEqual(commands, service.Commands);
Assert.AreEqual("title1", service.Title);
Assert.AreEqual(null, service.DocumentType);
Assert.AreEqual(null, service.Parameter);
Assert.AreEqual(viewModel, service.ViewModel);
Assert.AreEqual(null, service.ParentViewModel);
service = new TestDialogService();
commands = new List<UICommand>();
service.ShowDialog(commands, "title1", "docType", viewModel);
Assert.AreEqual(commands, service.Commands);
Assert.AreEqual("title1", service.Title);
Assert.AreEqual("docType", service.DocumentType);
Assert.AreEqual(null, service.Parameter);
Assert.AreEqual(viewModel, service.ViewModel);
Assert.AreEqual(null, service.ParentViewModel);
service = new TestDialogService();
service.ShowDialog(commands, "title3", "docType2", "param", parentViewModel);
Assert.AreEqual(commands, service.Commands);
Assert.AreEqual("title3", service.Title);
Assert.AreEqual("docType2", service.DocumentType);
Assert.AreEqual("param", service.Parameter);
Assert.AreEqual(null, service.ViewModel);
Assert.AreEqual(parentViewModel, service.ParentViewModel);
}
示例15: DefaultViewModelSerializer_NoEncryptedValues
public void DefaultViewModelSerializer_NoEncryptedValues()
{
var oldViewModel = new TestViewModel()
{
Property1 = "a",
Property2 = 4,
Property3 = new DateTime(2000, 1, 1),
Property4 = new List<TestViewModel2>()
{
new TestViewModel2() { PropertyA = "t", PropertyB = 15 },
new TestViewModel2() { PropertyA = "xxx", PropertyB = 16 }
},
Property5 = null
};
context.ViewModel = oldViewModel;
serializer.BuildViewModel(context);
var result = context.GetSerializedViewModel();
result = UnwrapSerializedViewModel(result);
result = WrapSerializedViewModel(result);
var newViewModel = new TestViewModel();
context.ViewModel = newViewModel;
serializer.PopulateViewModel(context, result);
Assert.AreEqual(oldViewModel.Property1, newViewModel.Property1);
Assert.AreEqual(oldViewModel.Property2, newViewModel.Property2);
Assert.AreEqual(oldViewModel.Property3, newViewModel.Property3);
Assert.AreEqual(oldViewModel.Property4[0].PropertyA, newViewModel.Property4[0].PropertyA);
Assert.AreEqual(oldViewModel.Property4[0].PropertyB, newViewModel.Property4[0].PropertyB);
Assert.AreEqual(oldViewModel.Property4[1].PropertyA, newViewModel.Property4[1].PropertyA);
Assert.AreEqual(oldViewModel.Property4[1].PropertyB, newViewModel.Property4[1].PropertyB);
Assert.AreEqual(oldViewModel.Property5, newViewModel.Property5);
}