Last active
December 11, 2015 21:19
-
-
Save shiftkey/4661947 to your computer and use it in GitHub Desktop.
Formatting strings - looks to be same between XAML and regular .NET code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Windows; | |
using System.Windows.Data; | |
using Xunit; | |
namespace ConsoleApplication2 | |
{ | |
public class Test | |
{ | |
DependencyObject dObj = new DependencyObject(); | |
[Fact] | |
public void Using_Binding_Should_Round_Down() | |
{ | |
// arrange | |
double second = 127.533; | |
var binding2 = new Binding { Source = second, StringFormat = "{0:0}" }; | |
var secondProperty = DependencyProperty.Register("Second", typeof(string), typeof(Program)); | |
BindingOperations.SetBinding(dObj, secondProperty, binding2); | |
// act | |
var oneTwoSeven = (string)dObj.GetValue(secondProperty); | |
Assert.Equal("127", oneTwoSeven); | |
} | |
[Fact] | |
public void Using_Defaults_Should_Round_Down() | |
{ | |
// arrange | |
double second = 127.533; | |
// act | |
var oneTwoSeven = second.ToString("0"); | |
Assert.Equal("127", oneTwoSeven); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment