Sliverlight单元测试
来源:互联网 发布:mac上好用的md编辑器 编辑:程序博客网 时间:2024/04/27 23:47
最近在做SliverLight beta2的控件单元测试.
控件界面调用:
using System;
using System.Windows;
using System.Windows.Controls;
using System.Collections.Generic;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Diagnostics;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Windows.Markup;
using System.Globalization;
using Microsoft.Silverlight.Testing.TestHarness;
using Zenexis.Controls.ColorPicker;
namespace SL.ColorPicker.UnitTest
{
[TestClass]
public class Z_ShowColorPicker:SilverlightTest
{
const int sleepTime = 800;
bool _isLoaded;
string testStr;
private bool IsLoaded()
{
return _isLoaded;
}
private Zenexis.Controls.ColorPicker.ColorPicker colorPicker;
[TestMethod]
[Description("Verify properties set on ColorPicker before load are reflected on the ColorPicker after load.")]
[Asynchronous]
[Owner("[....]")]
public void CPVerifyBeforeLoad()
{
colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
colorPicker.ColorSpace = Zenexis.Controls.ColorPicker.ColorSpace.RGB;
colorPicker.Color = Colors.Green;
colorPicker.ColorSelectionPanelVisibility = Visibility.Visible;
colorPicker.Tip = "Tip Message";
colorPicker.IsAutoSelect = true;
colorPicker.AutoSelectSeconds = 100;
colorPicker.IsHiddenColorSelectionPanelWhenAccept = false;
colorPicker.Loaded += new RoutedEventHandler(_elementToCleanUp_Loaded);
Silverlight.TestSurface.Children.Add(colorPicker);
EnqueueConditional(new Microsoft.Silverlight.Testing.ConditionalDelegate(IsLoaded));
EnqueueSleep(sleepTime);
EnqueueCallback(VerifyBeforeLoaded);
EnqueueTestComplete();
}
private void _elementToCleanUp_Loaded(object sender, RoutedEventArgs e)
{
_isLoaded = true;
}
private void VerifyBeforeLoaded()
{
Assert.AreEqual(colorPicker.Color, Colors.Green);
Assert.AreEqual(colorPicker.ColorSelectionPanelVisibility, Visibility.Visible);
Assert.AreEqual(colorPicker.ColorSpace, Zenexis.Controls.ColorPicker.ColorSpace.RGB);
Assert.AreEqual(colorPicker.Tip, "Tip Message");
Assert.IsTrue(colorPicker.IsAutoSelect);
Assert.AreEqual(colorPicker.AutoSelectSeconds, 100);
Assert.IsFalse(colorPicker.IsHiddenColorSelectionPanelWhenAccept);
colorPicker.ColorSelectionPanelVisibility = Visibility.Collapsed;
}
[TestMethod]
[Description("Ensure Collapsed/Expanded events are fired.")]
[Asynchronous]
[Owner("[....]")]
public void DPCalendarClosedEvent()
{
colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
Silverlight.TestSurface.Children.Add(colorPicker);
colorPicker.Collapsed += new RoutedEventHandler(delegate
{
testStr = "Color Selection Collapsed!";
});
colorPicker.Expanded += new RoutedEventHandler(delegate
{
testStr = "Color Expanded Opened!";
});
}
}
}
属性和Events测试.
namespace SL.ColorPickerUnitTesting
{
[TestClass]
public class ColorPickerTest : SilverlightTest
{
//const int sleepTime = 800;
//bool _isLoaded;
//string testStr;
//private bool IsLoaded()
//{
// return _isLoaded;
//}
//private Zenexis.Controls.ColorPicker.ColorPicker colorPicker;
[TestMethod]
[Owner("[]")]
[Description("Create a ColorPicker Control.")]
public void CreateColorPicker()
{
Zenexis.Controls.ColorPicker.ColorPicker colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
Assert.IsNotNull(colorPicker);
}
[TestMethod]
[Owner("[]")]
[Description("Ensure that SelectedColorsChanged event is fired.")]
public void SelectedColorsChangedEvent()
{
string testString = null;
Zenexis.Controls.ColorPicker.ColorPicker colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
colorPicker.SelectedColorChanged += new Zenexis.Controls.ColorPicker.ColorPicker.SelectedColorChangedEventHandler
(delegate
{
testString = "Handled!";
}
);
colorPicker.SelectedColor = Colors.Blue;
Assert.AreNotEqual(testString, "Handled!");
}
[TestMethod]
[Owner("[]")]
[Description("Ensure that all default values are correct")]
public void ColorPickCheckedDefaultValues()
{
Zenexis.Controls.ColorPicker.ColorPicker colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
Assert.IsTrue(colorPicker.IsEnabled, "element is disabled in UI");
Assert.IsTrue(colorPicker.IsHiddenColorSelectionPanelWhenAccept, "hiding color selection panel fails.");
Assert.IsFalse(colorPicker.IsAutoAccept, "Accepting mode automatically fails.");
Assert.AreEqual(colorPicker.AutoSelectSeconds, 2);
Assert.AreEqual(colorPicker.ColorSelectionPanelVisibility, Visibility.Collapsed);
Assert.AreEqual(colorPicker.CurrentColorPanelVisibility, Visibility.Visible);
}
//[TestMethod]
//[Description("Verify properties set on ColorPicker before load are reflected on the ColorPicker after load.")]
//[Asynchronous]
//[Owner("[....]")]
//public void CPVerifyBeforeLoad()
//{
// colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
// colorPicker.ColorSpace = Zenexis.Controls.ColorPicker.ColorSpace.RGB;
// colorPicker.Color = Colors.Green;
// colorPicker.ColorSelectionPanelVisibility = Visibility.Visible;
// colorPicker.Tip = "Tip Message";
// colorPicker.IsAutoSelect = true;
// colorPicker.AutoSelectSeconds = 100;
// colorPicker.IsHiddenColorSelectionPanelWhenAccept = false;
// colorPicker.Loaded += new RoutedEventHandler(_elementToCleanUp_Loaded);
// Silverlight.TestSurface.Children.Add(colorPicker);
// EnqueueConditional(new Microsoft.Silverlight.Testing.ConditionalDelegate(IsLoaded));
// EnqueueSleep(sleepTime);
// EnqueueCallback(VerifyBeforeLoaded);
// EnqueueTestComplete();
//}
[TestMethod]
[Owner("[]")]
[Description("Ensure that IsEnabled1 property can be set")]
public void SetIsEnable1()
{
Zenexis.Controls.ColorPicker.ColorPicker colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
Assert.IsTrue(colorPicker.IsEnabled);
colorPicker.IsEnabled = false;
Assert.IsFalse(colorPicker.IsEnabled);
colorPicker.IsEnabled = true;
Assert.IsTrue(colorPicker.IsEnabled);
}
[TestMethod]
[Owner("[]")]
[Description("Ensure that IsHiddenColorSelectionPanelWhenAccept property can be set ")]
public void SetIsHiddenColorSelectionPanelWhenAccept()
{
Zenexis.Controls.ColorPicker.ColorPicker colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
Assert.IsTrue(colorPicker.IsHiddenColorSelectionPanelWhenAccept);
colorPicker.IsHiddenColorSelectionPanelWhenAccept = false;
Assert.IsFalse(colorPicker.IsHiddenColorSelectionPanelWhenAccept);
colorPicker.IsHiddenColorSelectionPanelWhenAccept = true;
Assert.IsTrue(colorPicker.IsHiddenColorSelectionPanelWhenAccept);
}
[TestMethod]
[Owner("[]")]
[Description("Ensure that IsAutoAccept property can be set.")]
public void SetIsAutoAccept()
{
Zenexis.Controls.ColorPicker.ColorPicker colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
colorPicker.IsAutoAccept = true;
Assert.IsTrue(colorPicker.IsAutoAccept);
colorPicker.IsAutoAccept = false;
Assert.IsFalse(colorPicker.IsAutoAccept);
colorPicker.IsAutoAccept = true;
Assert.IsTrue(colorPicker.IsAutoAccept);
}
//private void _elementToCleanUp_Loaded(object sender, RoutedEventArgs e)
//{
// _isLoaded = true;
//}
//private void VerifyBeforeLoaded()
//{
// Assert.AreEqual(colorPicker.Color, Colors.Green);
// Assert.AreEqual(colorPicker.ColorSelectionPanelVisibility, Visibility.Visible);
// Assert.AreEqual(colorPicker.ColorSpace, Zenexis.Controls.ColorPicker.ColorSpace.RGB);
// Assert.AreEqual(colorPicker.Tip, "Tip Message");
// Assert.IsTrue(colorPicker.IsAutoSelect);
// Assert.AreEqual(colorPicker.AutoSelectSeconds, 100);
// Assert.IsFalse(colorPicker.IsHiddenColorSelectionPanelWhenAccept);
// colorPicker.ColorSelectionPanelVisibility = Visibility.Collapsed;
//}
//[TestMethod]
//[Description("Ensure Collapsed/Expanded events are fired.")]
//[Asynchronous]
//[Owner("[....]")]
//public void DPCalendarClosedEvent()
//{
// colorPicker = new Zenexis.Controls.ColorPicker.ColorPicker();
// Silverlight.TestSurface.Children.Add(colorPicker);
// colorPicker.Collapsed += new RoutedEventHandler(delegate
// {
// testStr = "Color Selection Collapsed!";
// });
// colorPicker.Expanded += new RoutedEventHandler(delegate
// {
// testStr = "Color Expanded Opened!";
// });
//}
}
}
- Sliverlight单元测试
- 《sliverlight揭秘》
- sliverlight HyperlinkButton
- sliverlight:TabControl
- Sliverlight Binding
- SliverLight的官方介绍
- sliverlight中文学习网站
- Sliverlight网站收集
- sliverlight入门指南
- sliverlight + wcf +datagrid
- Sliverlight change the scene
- sliverlight 连接wcf
- sliverlight :Local connection
- sliverLight 图表实例
- sliverlight 资源动态调用
- sliverLight 控件应用地址
- sliverlight for embedded
- SliverLight 练习1
- ajax
- Unicode与字符集函数
- 写了一个生成迷宫的算法:),贴代码,效果见 http://www.dullwolf.cn/Wall/
- 关于 face='Webdings'
- uclinux-2008R1-RC8(bf561)到VDSP5的移植(63): 网卡驱动
- Sliverlight单元测试
- 疯狂的程序员73
- 联想:“荣号易得,质量难求!”
- 中国象棋与人工智能的研究成果
- Perl DBI模块的例子
- 不知天天听英语晨读四六级之类的MP3,对学英语有没有帮助
- jstl c 标签(1)
- 高效能人士的七个习惯
- 推荐几款ASP.NET文本编辑器