Ȥ Blog

Ruby,C#

2011ǯ05

Apple MagicTrackPadȤ³

2,3ֻȤ³ޤ⤦ޥפʤȤˤʤޤ
ӤưʤФʤʤޥ٤ơǺѤǤޤγڤϡƤޤȡޥפ⤫ФʤʤäƤޤޤ
Τϴ⤢ΤǡդϺǽϸǤäƤ⤹ʤȻפޤ
Ϥޤ

ǡ
  • ޥۤ䥿֥åȤǸ褦ˡޥå㡼ϰ̲Ǥ
  • Ρȥ֥åϥȥåѥåɡǥȥåפϥޥȤäڤؤסǤФɤäȤƱɤǤ͡
  • MacOSLionˤǤϥޥå㡼Ƴ͡
äƤȤͤȡäѤꤳäʡȤǡ
 

mono


http://www.infoq.com/jp/news/2011/05/Mono-II

äMonoTouchȤϤ᤿ФʤΤˡNovelAttachmateȤɥĤδȤMonoڤΤƤƤޤä褦Ǥ
ǡ꡼οͤϿҤΩ夲ƤMono³͡
Ҥϡ 
http://www.xamarin.com/

ޤȥåץڡʤߤ

⤦ʤäMicrosoftLinuxOSX.NET FrameworkФƤʤʡ
Ф졢Mono!!

C#iPhone HelloWorldäƤߤ

褦䤯ˤʤäMonoTouchȤäC#iPhoneץƤߤޤ
HelloWorld٥ΤΤǤ䡼äѤC#ǺäƤʡȻפޤ
ä˻ŻJavaФä꿨äƤΤǡۤȤäȤûɤǤ줿äƥۥȵ 

Windows Vista or 7 64bitǤ PrintDialogǽʤ

äȰ.NET Framework2.0ǿäˤ˺äץǡǤʤΤľƤ졢Ȥΰ꤬ꡢĴȤɤ64ӥåǤWindowsξΤߤȯ븽ݤΤ褦
ǡ꡼󥭥פΤ뵡ǽǡץ㤹ΤWindowsAPIȤäƤ顢դʡ Ǥ⡢.NET Framework2.0饹꡼󥭥ץ㤹APIɲäƤߤʺΤäˤĤ˽񤭴ƻƤߤ褦ȤȤǡäΤǤȤ⤹Ȥʤ
ɤ PintDialog.Show ǻߤޤäƤ롢Ȥⵯʤʥ顼ˤʤ櫓Ǥʤˡ

windows 64bit PrintDialog Ǥä顢

PrintDialog.UseEXDialog ץѥƥ

 ȤΤꡢMSDNΥɥȤȡ

AMD64 ץåξ硢Υ饹ϡUseEXDialog ץѥƥ true ꤷʤưʤǽޤ
ȤΤȡ

ʤ졩 Ȼפʤ®ץѥƥTrue򥻥åȤơ¹ԤƤߤ顢äOK

1֤λԺ̵̤ä褦Ǥ
 
MSDNɤǤ⤳ΥץѥƥڤʤȤΤ 

NUnitη̤HTMLɽ

.NETǤSpecFlowɥˤäSpecƥȤ뤳ȤϤ狼äΤǤ̤HTMLɽǤߤʤȤ⥬ɤ˽񤤤Ƥޤ
ǡɤ Ȥ褯ɤǤߤ
  1. nunit-console ǥƥȥץȤ¹ԤXMLե
  2. specflow.exe HTML
ƤʼǤ褦Ǥ


ʴ
ĶMacmonoǤ


#MySpec.dllϥƥȥץ(nUnit)
nunit-console -labels -out=TestResult.txt -xml=TestResult.xml ./bin/Debug/MySpec.dll


mono specFlowषǥ쥯ȥ/tools/specflow.exe nunitexecutionreport ./MySpec.csproj


ȤäƤȡʴHTML롣
ƥ3Ĥʤ䤷features 0 äƤΤ褯狼ʤ
10



MonoDevelop (C#) SpecȤäƥƥȤ񤤤Ƥߤ

ǶJavaȤŻ򤷤ƤΤǡǯ֤xUnitȤäƥȤ񤤤ƤΤǤäѤͤƥȥɾľɽǤSpecϹǤ
ǡäĴ٤VisualStudioΥɥSpecFlowʤΤ뤳ȤȯǡĤǤMonoDevelopǤ⤢뤳ȤȯοJavaϡʤScalaȤäΤϤ褦ǤޤޤjUnitήΤ褦ǤޤJava餳ϻʤ

Ȥ櫓ǺMonoDevelopȤäC#SpecƥȤ񤤤Ƥߤ

MonoDevelop Tool -> Add-in Manager SpecFlow Support򥤥󥹥ȡ롣
27

SpecFlowΥȤ顢ȤGitHubdllɡ
http://specflow.org/home.aspx
WindowsǤmsi󥹥ȡǤѰդƤޤʳξZIPեɡषƻȤɬפޤ

­򤹤륯饹ΥƥȤSpecFlowȤäƽ񤤤Ƥߤ롣
ޤNunitLibraryProjectMySpecȤ̾ǿƤߤ롣ȤΤSpecFlowNUnitȤäƤΤǡǥեȤNunitΥ饤֥򻲾Ȥ褦ꤷƤNunitLibraryProjectäȳڤ顣
23

˥饤֥λȤǥɡषTechTalk.SpecFlow.dllɲá
01

ˡեο SpecFlowFeatureɲáǤCalculator.featureȤ̾ǺäƤߤ롣
32

ץȤƤʴΥΤ񤫤Ƥ롣

		Feature: Addition
			In order to avoid silly mistakes
			As a math idiot
			I want to be told the sum of two numbers

		@mytag
		Scenario: Add two numbers
			Given I have entered 50 into the calculator
			And I have entered 70 into the calculator
			When I press add
			Then the result should be 120 on the screen
	
ƬFeature: ʬϥȥȥե꡼ƥȤϲǽǡޤʵǽΥƥȤ򤷤ޤ衼ŪʤȤ񤤤ȤФȻפޤ
ǡScenarioäƤΤ줾Υƥȥ񤯤ȤΤ褦¿ʬ̣
  • Given : ξŪʤȡʡξˡ
  • When : ƥоݤŪʤȡʡ򤷤
  • Then : ̡~ˤʤϤ
ƤʴȻפޤ
ξȡ5070Ϥơadd򲡤顢̤120ɽϤƤʥƥȤˤʤޤ

Ȥꤢξ֤ǥƥȤ¹ԤƤߤȷ̤Ϥʴˤʤ롣
44

		Running MySpec.MySpec.MySpec.AdditionFeature.AddTwoNumbers ...
		Given I have entered 50 into the calculator
		-> No matching step definition found for the step. Use the following code to create one:
		    [Binding]
		    public class StepDefinitions
		    {
		        [Given(@"I have entered 50 into the calculator")]
		        public void GivenIHaveEntered50IntoTheCalculator()
		        {
		            ScenarioContext.Current.Pending();
		        }
		    }

		And I have entered 70 into the calculator
		-> No matching step definition found for the step. Use the following code to create one:
		    [Binding]
		    public class StepDefinitions
		    {
		        [Given(@"I have entered 70 into the calculator")]
		        public void GivenIHaveEntered70IntoTheCalculator()
		        {
		            ScenarioContext.Current.Pending();
		        }
		    }

		When I press add
		-> No matching step definition found for the step. Use the following code to create one:
		    [Binding]
		    public class StepDefinitions
		    {
		        [When(@"I press add")]
		        public void WhenIPressAdd()
		        {
		            ScenarioContext.Current.Pending();
		        }
		    }

		Then the result should be 120 on the screen
		-> No matching step definition found for the step. Use the following code to create one:
		    [Binding]
		    public class StepDefinitions
		    {
		        [Then(@"the result should be 120 on the screen")]
		        public void ThenTheResultShouldBe120OnTheScreen()
		        {
		            ScenarioContext.Current.Pending();
		        }
		    }
	
ƥåȤΤɬפˤʤäƤ餷Ȥ櫓ǥƥåȤɲäƤߤ롣

եοǡSpecFlow Spec Definition򤷤ŬCalculatorStepȤ̾ǺäƤߤȡץ륳Υե뤬ΤǡȤꤢץΥ᥽åɤƺȤʴ 58

		using System;

		using TechTalk.SpecFlow;

		namespace MySpec
		{
			[Binding]
			public class CalculatorStep
			{
			}
		}
	

ǡǾ嵭ƥȤμ¹Է̤ˤ٤᥽åɤ򥳥ԥڤŽդ롣Ȥʴˤʤ롣

		using System;
		using TechTalk.SpecFlow;

		namespace MySpec
		{
			[Binding]
			public class CalculatorStep
			{
				[Given(@"I have entered 50 into the calculator")]
				public void GivenIHaveEntered50IntoTheCalculator ()
				{
					ScenarioContext.Current.Pending ();
				}

				[Given(@"I have entered 70 into the calculator")]
				public void GivenIHaveEntered70IntoTheCalculator ()
				{
					ScenarioContext.Current.Pending ();
				}

				[When(@"I press add")]
				public void WhenIPressAdd ()
				{
					ScenarioContext.Current.Pending ();
				}

				[Then(@"the result should be 120 on the screen")]
				public void ThenTheResultShouldBe120OnTheScreen ()
				{
					ScenarioContext.Current.Pending ();
				}
			}
		}

	
ǥƥȤ¹ԤȤäȤϰäåˤʤ롣
		Running MySpec.MySpec.MySpec.AdditionFeature.AddTwoNumbers ...
		Given I have entered 50 into the calculator
		-> pending: CalculatorStep.GivenIHaveEntered50IntoTheCalculator()
		And I have entered 70 into the calculator
		-> skipped because of previous errors
		When I press add
		-> skipped because of previous errors
		Then the result should be 120 on the screen
		-> skipped because of previous errors
	

ޤºݤưCalculator饹ʤƤΤϤʤɡΥʥꥪ̤˥ƥȥɤ񤤤Ƥߤ롣ξ硢ޤʪʤΤǡ˸ƤӽФ¦Ωǥ᥽å̾Ȥͤ롢

		using System;
		using NUnit.Framework;
		using TechTalk.SpecFlow;

		namespace MySpec
		{
			[Binding]
			public class CalculatorStep
			{

				Calculator target = new Calculator();

				[Given(@"I have entered 50 into the calculator")]
				public void GivenIHaveEntered50IntoTheCalculator ()
				{
					target.Enter (50);
				}

				[Given(@"I have entered 70 into the calculator")]
				public void GivenIHaveEntered70IntoTheCalculator ()
				{
					target.Enter (70);
				}

				[When(@"I press add")]
				public void WhenIPressAdd ()
				{
					target.PressAdd ();
				}

				[Then(@"the result should be 120 on the screen")]
				public void ThenTheResultShouldBe120OnTheScreen ()
				{
					Assert.AreEqual (120, target.Result);
				}
			}
		}
	
ʳǤɥƥȤϤѥ̤ʤ

㤢ºݤư饹 Calculator롣
Add New ProjectǡץȤɲá̾ŬCalcȤƤߤ롣
01

ǡΥץȤCalculator饹ɲá
59

ǡɬפʥ᥽åɤ򡢥ץѥƥΥȥȡʴ

		using System;
		namespace Calc
		{
			public class Calculator
			{
				public int Result { get; set; }

				public Calculator ()
				{
				}

				public void Enter (int number)
				{
				}

				public void PressAdd ()
				{ 
				}
			}
		}
	

ˡƥȥץȤǡΥ饹򻲾ȤǤ褦˥饤֥껲ȤǥץȻȤusingɲá
07
18

		using System;
		using NUnit.Framework;
		using TechTalk.SpecFlow;
		using Calc;
	
ǥƥȤ¹ԤƤߤȡ̤ϤȼԤ롣
39

ǡ٤ϥƥȤ̤褦Calculator饹Υ᥽åɤȤ롣ȤꤢʴǼƤߤ롣

		using System;
		using System.Collections.Generic;

		namespace Calc
		{
			public class Calculator
			{

				List _numbers = new List(2);
				public int Result { get; set; }

				public Calculator ()
				{
				}

				public void Enter (int number)
				{
					_numbers.Add (number);
				}

				public void PressAdd ()
				{ 
					_numbers.ForEach( number => this.Result += number);			
				}
			}
		}
	
ǡ٥ƥȤ¹ԤƤߤ롣
48
ȥ꡼

Ǥ⤳δȡEnter(50), Enter(70)Ȥ줾˥ƥå˥᥽åɤäơ㤢80ϤΥƥȤ񤯾ϡʴ٥᥽åɤɲäƤΤȤ䤬

		//ѥ᡼˥᥽åɤɬס
		[Given(@"I have entered 80 into the calculator")]
		public void GivenIHaveEntered80IntoTheCalculator ()
		{
			target.Enter (80);
		}
	
¤ϤդѰդƤơɽȤäƥѥ᡼Ǥꤷޤǡfeatureȥƥå򤳤ʴǽ񤭴Ƥߤ롣
feature
		Feature: Addition
			In order to avoid silly mistakes
			As a math idiot
			I want to be told the sum of two numbers

		@mytag
		Scenario: Add two numbers
			Given I have entered "50" into the calculator
			And I have entered "70" into the calculator
			When I press add
			Then the result should be "120" on the screen
	
ƥå:
		using System;
		using NUnit.Framework;
		using TechTalk.SpecFlow;
		using Calc;

		namespace MySpec
		{
			[Binding]
			public class CalculatorStep
			{

				Calculator target = new Calculator();

				//[Given(@"I have entered 50 into the calculator")]
				[Given(@"I have entered ""(\d+)"" into the calculator")]
				public void GivenIHaveEnteredNumberIntoTheCalculator (int number)
				{
					target.Enter (number);
				}

		//		[Given(@"I have entered 70 into the calculator")]
		//		public void GivenIHaveEntered70IntoTheCalculator ()
		//		{
		//			target.Enter (70);
		//		}

				[When(@"I press add")]
				public void WhenIPressAdd ()
				{
					target.PressAdd ();
				}

				//[Then(@"the result should be 120 on the screen")]
				[Then(@"the result should be ""(\d+)"" on the screen")]
				public void ThenTheResultShouldBeOnTheScreen (int result)
				{
					Assert.AreEqual (result, target.Result);
				}
			}
		}
	
featureϥѥ᡼֥ͤ륯ơǰϤߤޤ
ƥåϳƥ᥽åɤAttributeǥѥ᡼ʬɽѥ֤ޤǤintϤΤǿͰʳդʤ褦ˤƤ롣

äƤߤäѤxUnitSpecǤ͡
ޤ̤HTMLɽꡢȤȤǤꤹ褦ǤܤϲΥȤȤɤ򤴻Ȥ
http://specflow.org/home.aspx
http://github.com/downloads/techtalk/SpecFlow/SpecFlow%20Guide.pdf

Apple ޥåȥåѥåɤ㤦

ˤƵޤ˥ޥåȥåѥåɤߤʤäΤǡƤޤޤ
ľMacBookAirǻȤäƤȥꥢޤȤ䤹ȤϻפʤäɡäϸƤ̤꤫ʤѤä˻Ȥ䤹Ǥ

ǰƤƥȤ䡢ɽ׻եȤΥΥĴʤɤʤǤơȴǤMacBookAirǤɤȴΤϤäѤ궹ʤΤ

ޤեåϤΥեȤϻƤʤΤDzȤޤ󤬡ʾ˲Ŭǡʲ٤ʴԤϤƤʤä餫12֤ۤɻѤơޥʥޥåޥˤŸ򥪥դäƤޤޤʤäϿǻȤʡˡ

ޥȥåܡѹ褦Ȥ2餤ɡɤƤʤäΤˡäɤΤʤ
ƤĿŪˤϥޥåޥɤǤ


IMG_0478




ץե

Ȥ

C#ɻŻRubyФʳȯԡ
ǶDockerȤؿȤAngularJS˥ϥޤäƤ롣
¢ȤĮȤȤ˽ס

QR
QR
  • 饤֥ɥ֥