зеркало из https://github.com/xamarin/Touch.Unit.git
Update Touch.Unit to build/run using NUnitLite 0.9
This commit is contained in:
Родитель
294d0663fc
Коммит
f32d4c9144
|
@ -3,7 +3,7 @@
|
|||
// Authors:
|
||||
// Sebastien Pouliot <sebastien@xamarin.com>
|
||||
//
|
||||
// Copyright 2011-2012 Xamarin Inc.
|
||||
// Copyright 2011-2013 Xamarin Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -45,7 +45,7 @@ namespace MonoTouch.NUnit {
|
|||
runner.Add (Assembly.GetExecutingAssembly ());
|
||||
// otherwise you need to ensure that the test assemblies will
|
||||
// become part of the app bundle
|
||||
runner.Add (typeof (MonoTouchFixtures.RegressionTest).Assembly);
|
||||
runner.Add (typeof (MonoTouchFixtures.Test.Test).Assembly);
|
||||
#if false
|
||||
// you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
|
||||
runner.Writer = new TcpTextWriter ("10.0.1.2", 16384);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<key>CFBundleIdentifier</key>
|
||||
<string>com.xamarin.touch-unit</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>3.0</string>
|
||||
<string>4.0</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<string>1</string>
|
||||
|
|
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
|||
MDTOOL=/Applications/MonoDevelop.app/Contents/MacOS/mdtool
|
||||
MDTOOL="/Applications/Xamarin Studio.app/Contents/MacOS/mdtool"
|
||||
MTOUCH=/Developer/MonoTouch/usr/bin/mtouch
|
||||
TOUCH_SERVER=./Touch.Server/bin/Debug/Touch.Server.exe
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -72,7 +72,7 @@ namespace MonoTouch.NUnit.UI {
|
|||
int counter = Result.AssertCount;
|
||||
Value = String.Format ("{0} {1} ms for {2} assertion{3}",
|
||||
Result.IsInconclusive () ? "Inconclusive." : "Success!",
|
||||
Result.Time * 1000, counter,
|
||||
Result.Duration.TotalMilliseconds * 1000, counter,
|
||||
counter == 1 ? String.Empty : "s");
|
||||
DetailColor = DarkGreen;
|
||||
} else if (Result.IsFailure ()) {
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace MonoTouch.NUnit.UI {
|
|||
StringBuilder sb = new StringBuilder ();
|
||||
if (failure == 0) {
|
||||
DetailColor = DarkGreen;
|
||||
sb.Append ("Success! ").Append (Result.Time * 1000).Append (" ms for ").Append (positive).Append (" test");
|
||||
sb.Append ("Success! ").Append (Result.Duration.TotalMilliseconds * 1000).Append (" ms for ").Append (positive).Append (" test");
|
||||
if (positive > 1)
|
||||
sb.Append ('s');
|
||||
} else {
|
||||
|
|
|
@ -394,7 +394,7 @@ namespace MonoTouch.NUnit.UI {
|
|||
|
||||
string name = result.Test.Name;
|
||||
if (!String.IsNullOrEmpty (name))
|
||||
Writer.WriteLine ("{0} : {1} ms", name, result.Time * 1000);
|
||||
Writer.WriteLine ("{0} : {1} ms", name, result.Duration.TotalMilliseconds * 1000);
|
||||
} else {
|
||||
if (result.IsSuccess ()) {
|
||||
Writer.Write ("\t[PASS] ");
|
||||
|
|
|
@ -12,15 +12,13 @@
|
|||
|
||||
1. Clone all the required code from github.com
|
||||
|
||||
$ git clone git://github.com/spouliot/MonoTouch.Dialog.git
|
||||
|
||||
$ git clone git://github.com/spouliot/NUnitLite.git
|
||||
|
||||
$ git clone git://github.com/spouliot/Touch.Unit.git
|
||||
|
||||
note: make sure to pull from all of them to get the latest fixes
|
||||
|
||||
2. Launch MonoDevelop (2.8 or later)
|
||||
2. Launch Xamarin Studio (4.0 or later)
|
||||
|
||||
3. Open the "Touch.Unit.sln" solution
|
||||
|
||||
|
@ -32,6 +30,6 @@
|
|||
|
||||
## Todo List
|
||||
|
||||
* Track changes in [iOS](http://developer.apple.com/devcenter/ios/index.action), [MonoTouch](http://ios.xamarin.com), [NUnitLite](http://www.nunitlite.org/index.php?p=roadmap) and [MonoTouch.Dialog](https://github.com/migueldeicaza/MonoTouch.Dialog)
|
||||
* Track changes in [iOS](http://developer.apple.com/devcenter/ios/index.action), [Xamarin.iOS](http://ios.xamarin.com), [NUnitLite](http://www.nunitlite.org/index.php?p=roadmap) and [MonoTouch.Dialog](https://github.com/migueldeicaza/MonoTouch.Dialog)
|
||||
|
||||
* otherwise KISS - want something more, fork it :-)
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<Variable name="VALGRIND2" value="/usr/local/bin/valgrind --tool=memcheck" />
|
||||
</EnvironmentVariables>
|
||||
</EnvironmentVariables>
|
||||
<MtouchArch>ARMv7</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
|
|
|
@ -1,258 +0,0 @@
|
|||
//
|
||||
// Copyright 2011-2012 Xamarin Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using Mono.Data.Sqlite;
|
||||
using MonoTouch.AddressBookUI;
|
||||
using MonoTouch.CoreAnimation;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.MapKit;
|
||||
using MonoTouch.UIKit;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTouchFixtures {
|
||||
|
||||
[TestFixture]
|
||||
// we want the test to be availble if we use the linker
|
||||
[Preserve (AllMembers = true)]
|
||||
public class RegressionTest {
|
||||
|
||||
[Test]
|
||||
// https://github.com/xamarin/monotouch/commit/cbefbeaea2eda820dfc7214e976edc83a55df38e
|
||||
public void MonoAssembly_LinkedOut ()
|
||||
{
|
||||
Assembly a = Assembly.GetExecutingAssembly ();
|
||||
Assert.That (a.GetType ().Name, Is.EqualTo ("MonoAssembly"), "MonoAssembly");
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=205
|
||||
// https://bugzilla.novell.com/show_bug.cgi?id=688414
|
||||
public void Bug205_ExposingIEnumerable ()
|
||||
{
|
||||
var ds = new DataContractSerializer (typeof (IEnumerable<int>));
|
||||
using (var xw = XmlWriter.Create (System.IO.Stream.Null))
|
||||
ds.WriteObject (xw, new int [] { 1, 2, 3 });
|
||||
// the above should not throw System.Runtime.Serialization.SerializationException
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=233
|
||||
public void Bug233_MonoPInvokeCallback ()
|
||||
{
|
||||
var c = new SqliteConnection ("Data Source=:memory:");
|
||||
c.Open ();
|
||||
c.Update += (sender, e) => {};
|
||||
// the above should not crash
|
||||
c.Close ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=234
|
||||
public void Bug234_Interlocked ()
|
||||
{
|
||||
string str = null;
|
||||
Assert.Null (Interlocked.Exchange (ref str, "one"), "Exchange");
|
||||
// the above should not crash with System.ExecutionEngineException
|
||||
Assert.That (str, Is.EqualTo ("one"), "one");
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=300
|
||||
// http://stackoverflow.com/questions/6517736/monotouch-crash-dictionary-firstordefault-type-initializer-predicateof
|
||||
public void Bug300_Linker_PredicateOf ()
|
||||
{
|
||||
Dictionary<string, DateTime> queued = new Dictionary<string, DateTime> ();
|
||||
KeyValuePair<string, DateTime> valuePair = queued.FirstOrDefault ();
|
||||
// above should not crash with System.ExecutionEngineException
|
||||
Assert.NotNull (valuePair);
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=328
|
||||
public void Bug328_CompletionBlock ()
|
||||
{
|
||||
CATransaction.Begin ();
|
||||
CATransaction.CompletionBlock = delegate {};
|
||||
// the above should not crash with a MonoTouchException
|
||||
CATransaction.Commit ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=769
|
||||
public void Bug769_UnregistredDelegate ()
|
||||
{
|
||||
Assert.NotNull (new MKMapViewDelegate ());
|
||||
// the above should not throw an Exception
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=865
|
||||
public void Bug865_CanOpenUrl ()
|
||||
{
|
||||
Assert.False (UIApplication.SharedApplication.CanOpenUrl (null), "null");
|
||||
// the above should not throw an ArgumentNullException
|
||||
// and that's important because NSUrl.FromString and NSUrl.ctor(string) differs
|
||||
const string bad_tel = "tel://1800 023 009";
|
||||
Assert.Null (NSUrl.FromString (bad_tel), "bad url");
|
||||
NSUrl url = new NSUrl (bad_tel);
|
||||
Assert.NotNull (url, "ctor, bad url");
|
||||
Assert.That (url.Handle, Is.EqualTo (IntPtr.Zero), "null handle");
|
||||
}
|
||||
|
||||
[Test]
|
||||
// issue indirectly found when trying: http://bugzilla.xamarin.com/show_bug.cgi?id=928
|
||||
// similar to MonoAssembly_LinkedOut
|
||||
// https://github.com/xamarin/monotouch/commit/409316f87f23723a384cb072163abd03ae7e6045
|
||||
public void Bug928_MonoModule_LinkedOut ()
|
||||
{
|
||||
Module m = Assembly.GetExecutingAssembly ().ManifestModule;
|
||||
Assert.That (m.GetType ().Name, Is.EqualTo ("MonoModule"), "MonoModule");
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=980
|
||||
public void Bug980_AddressBook_NRE ()
|
||||
{
|
||||
ABPeoplePickerNavigationController picker = new ABPeoplePickerNavigationController ();
|
||||
Assert.NotNull (picker.AddressBook); // no NRE should occur
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=1144
|
||||
[ExpectedException (typeof (NotSupportedException))]
|
||||
public void Bug1144_LinkedAway ()
|
||||
{
|
||||
Socket socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
|
||||
IAsyncResult ias = socket.BeginConnect (IPAddress.Loopback, 4201, null, null);
|
||||
ias.AsyncWaitHandle.WaitOne (15, true);
|
||||
// emitContext == true should behave identically whether the app is linked (throws) or not (bug)
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=1387
|
||||
public void Bug1387_UIEdgeInsets_ToString ()
|
||||
{
|
||||
var insets = new MonoTouch.UIKit.UIEdgeInsets (1, 2, 3, 4);
|
||||
Assert.That (insets.ToString (), Is.Not.EqualTo ("MonoTouch.UIKit.UIEdgeInsets"));
|
||||
}
|
||||
|
||||
void CheckExceptionDetailProperty (PropertyInfo pi)
|
||||
{
|
||||
bool data_member = true;
|
||||
foreach (var ca in pi.GetCustomAttributes (false)) {
|
||||
if (ca is DataMemberAttribute) {
|
||||
data_member = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// to be valid both getter and setter must be present if [DataMember]
|
||||
if (data_member) {
|
||||
Assert.NotNull (pi.GetGetMethod (true), "get_" + pi.Name);
|
||||
Assert.NotNull (pi.GetSetMethod (true), "set_" + pi.Name);
|
||||
} else {
|
||||
// check well-known [DataMember]
|
||||
switch (pi.Name) {
|
||||
case "HelpLink":
|
||||
case "InnerException":
|
||||
case "Message":
|
||||
case "StackTrace":
|
||||
case "Type":
|
||||
Assert.Fail ("{0} is missing it's [DataMember] attribute", pi.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=1415
|
||||
public void Bug1415_Linker_DataMember ()
|
||||
{
|
||||
// the typeof ensure we're can't (totally) link away System.ServiceModel.dll
|
||||
Type ed = typeof (System.ServiceModel.AuditLevel).Assembly.GetType ("System.ServiceModel.ExceptionDetail", false);
|
||||
// which means it's [DataContract] / [DataMember] should not be linked out
|
||||
// even if we're not specifically using them (and without [Preserve] being added)
|
||||
// which is important since System.ServiceModel.dll is an SDK assembly
|
||||
Assert.NotNull (ed, "ExceptionDetail");
|
||||
bool help_link = false;
|
||||
bool inner_exception = false;
|
||||
bool message = false;
|
||||
bool stack_trace = false;
|
||||
bool type = false;
|
||||
foreach (var pi in ed.GetProperties ()) {
|
||||
CheckExceptionDetailProperty (pi);
|
||||
switch (pi.Name) {
|
||||
case "HelpLink":
|
||||
help_link = true;
|
||||
break;
|
||||
case "InnerException":
|
||||
inner_exception = true;
|
||||
break;
|
||||
case "Message":
|
||||
message = true;
|
||||
break;
|
||||
case "StackTrace":
|
||||
stack_trace = true;
|
||||
break;
|
||||
case "Type":
|
||||
type = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// ensure all properties are still present
|
||||
Assert.True (help_link, "HelpLink");
|
||||
Assert.True (inner_exception, "InnerException");
|
||||
Assert.True (message, "Message");
|
||||
Assert.True (stack_trace, "StackTrace");
|
||||
Assert.True (type, "Type");
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=1415
|
||||
// not really part of the bug - but part of the same fix
|
||||
public void Bug1415_Linker_XmlAttribute ()
|
||||
{
|
||||
// the typeof ensure we're can't (totally) link away System.ServiceModel.dll
|
||||
Type ed = typeof (System.ServiceModel.AuditLevel).Assembly.GetType ("System.ServiceModel.EndpointAddress10", false);
|
||||
// type is decorated with both [XmlSchemaProvider] and [XmlRoot]
|
||||
Assert.NotNull (ed, "EndpointAddress10");
|
||||
|
||||
var q = new OpenTK.Quaternion ();
|
||||
Assert.Null (q.GetType ().GetProperty ("XYZ"), "XmlIgnore");
|
||||
// should be null if application is linked (won't be if "Don't link" is used)
|
||||
}
|
||||
|
||||
[Test]
|
||||
// http://bugzilla.xamarin.com/show_bug.cgi?id=1516
|
||||
public void Bug1516_Appearance_Linker ()
|
||||
{
|
||||
UINavigationBar.Appearance.TintColor = UIColor.FromRGB (238,234,222);
|
||||
UINavigationBar.Appearance.SetTitleTextAttributes (new UITextAttributes() {
|
||||
TextColor = UIColor.FromRGB(85, 108, 17),
|
||||
TextShadowColor = UIColor.Clear
|
||||
});
|
||||
// show not throw if the application is linked
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
//
|
||||
// Copyright 2011-2012 Xamarin Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
using System;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.ObjCRuntime;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTouchFixtures.ObjCRuntime {
|
||||
|
||||
[TestFixture]
|
||||
[Preserve (AllMembers = true)]
|
||||
public class RuntimeTest {
|
||||
|
||||
[Test]
|
||||
public void GetNSObject_IntPtrZero ()
|
||||
{
|
||||
Assert.Null (Runtime.GetNSObject (IntPtr.Zero));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void RegisterAssembly_null ()
|
||||
{
|
||||
Runtime.RegisterAssembly (null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,13 +30,7 @@
|
|||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="monotouch" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="Mono.Data.Sqlite" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
@ -46,8 +40,6 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="RegressionTest.cs" />
|
||||
<Compile Include="RuntimeTest.cs" />
|
||||
<Compile Include="TestTest.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Загрузка…
Ссылка в новой задаче