/
ModelBindingLogEndpointTester.cs
67 lines (58 loc) · 2.14 KB
/
ModelBindingLogEndpointTester.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Diagnostics;
using FubuCore;
using FubuCore.Binding;
using FubuCore.Binding.Logging;
using FubuCore.Descriptions;
using FubuCore.Reflection;
using FubuMVC.Core.Diagnostics.Runtime;
using FubuMVC.Core.UI.Bootstrap.Collapsibles;
using FubuMVC.Diagnostics.ModelBinding;
using FubuMVC.Diagnostics.Visualization.Visualizers;
using NUnit.Framework;
using FubuTestingSupport;
namespace FubuMVC.Diagnostics.Tests.Visualization.Visualizers
{
[TestFixture]
public class ModelBindingLogEndpointTester
{
private ModelBindingLog theLog;
[SetUp]
public void SetUp()
{
theLog = new ModelBindingLog(){
Report = new BindingReport(typeof (FakeModel), new FakeModelBinder())
};
}
[Test]
public void just_show_the_selected_model_binder_if_no_properties()
{
var tag = new ModelBindingFubuDiagnostics(null).VisualizePartial(theLog).As<CollapsibleTag>();
tag.ToString().ShouldContain("Used Title of FakeModelBinder");
}
[Test]
public void show_with_properties()
{
theLog.Report.AddProperty(ReflectionHelper.GetProperty<FakeModel>(x => x.Name), new ConversionPropertyBinder(new BindingRegistry()));
theLog.Report.Used(new BindingValue{RawKey = "somethingelse", RawValue = "raw", Source = "the request"});
var tag = new ModelBindingFubuDiagnostics(null).VisualizePartial(theLog).As<CollapsibleTag>();
tag.ToString().ShouldContain("<tr><td>Name</td><td>ConversionPropertyBinder</td><td>'raw' from 'the request'/somethingelse</td></tr>");
}
}
public class FakeModel
{
public string Name { get; set; }
}
[Title("Title of FakeModelBinder")]
public class FakeModelBinder : IModelBinder
{
public bool Matches(Type type)
{
throw new NotImplementedException();
}
public object Bind(Type type, IBindingContext context)
{
throw new NotImplementedException();
}
}
}