GUIã¢ããªã±ã¼ã·ã§ã³ã§å®é¨ã³ã¼ãæ¸ãã®ã£ã¦ã¡ãã£ã¨è¦çãããªãã§ããï¼å人çã«ã¯è¦çã§ããããã«ãMetroã¹ã¿ã¤ã«ã¢ããªãªã®ã§ç¾å¨ã®CPçã ã¨ããã¡ãã¡ã¤ã³ã¹ãã¼ã«ãããã¨ãã¥ã¬ã¼ã¿èµ·åããããã¨ã¡ãã£ã¨ã試ãããã®ã«ããããªãã§ãã
åä½ãã¹ãããããï¼
ã¨ãããã¨ã§ã©ããããã¨ããã¨åä½ãã¹ãããã®ãå人çã«ããããã§ãã確ãExpressçã§ãåä½ãã¹ãæ©è½ãµãã¼ããããã¨è¨æ¶ãã¦ããã®ã§ãããã使ã£ã¦ããã¾ãããï¼
ããæ¹
Windows Metro styleã®ä¸ã«ããåä½ãã¹ãã©ã¤ãã©ãªãé¸æãã¾ããããããã¨åä½ãã¹ãã¯ã©ã¹ãï¼ã¤ä½ãããããã¸ã§ã¯ããã§ããã®ã§ãããã«ã試ãã³ã¼ããæ¸ãã¦ããã¾ãã
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTestProject1 { [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { // ããã«ã試ãã³ã¼ãæ¸ãã¦Assertãã Assert.AreEqual("æå¾ å¤", "å®éã®å¤"); } } }
ããã§åä½ãã¹ãå®è¡ããã°ããã®ã§ããããã¡ãã¡åä½ãã¹ãã®å®è¡ãå½ä»¤ããã®ãããã©ãããã¨ãããã®ãããªäººã«ç´ æµãªæ©è½ã追å ããã¦ãã¾ããã¡ãã¥ã¼ã®ãåä½ãã¹ããâãåä½ãã¹ãè¨å®ãâãRun Tests After Buildãããã§ãã¯ãã¦ããã¾ããããããã¨è¨å®ã®ååã®éããã«ããããã³ã«åä½ãã¹ããå®è¡ããã¾ãï¼ï¼ã·ã§ã¼ãã«ããC#éçºã®è¨å®ã«ãã¦ã人ã¯ãF6ãããCtrl + Shift + Bãã§ããããã«ãããã¨ãåä½ãã¹ãã¨ã¯ã¹ããã¼ã©ã«ä»¥ä¸ã®ããã«çµæã表示ããã¾ããã¨ãã¥ã¬ã¼ã¿ã¨ãã§ãããããå人çã«ã¯ãæ軽ã§ãã
ã¡ãªã¿ã«ãã¹ãæåããã¨éã«ãªãã¾ãã
ã¾ã¨ã
ã¨ãããã¨ã§ãMetro ã¹ã¿ã¤ã«ã¢ããªã§å®é¨ã³ã¼ããæ¸ãã¨ãã¯åä½ãã¹ãããã£ãã»ããæãããã§ããåä½ãã¹ãã¨ã¯ã¹ããã¼ã©ã§å³åº§ã«çµæãããããã¨ãã¥ã¬ã¼ã¿ãèµ·åããªããããã¼ã«ã«ã«ãããã¢ããªã±ã¼ã·ã§ã³ãã¤ã³ã¹ãã¼ã«ããããã¨ããªãã§ãã
ããã¦ãåºæ¥ããã¨ãªãæ¬çªã¢ããªã±ã¼ã·ã§ã³ä½ãã¨ããåä½ãã¹ãããã¸ã§ã¯ããä½ã£ã¦ããã¦æ¸ããã³ã¼ããå³åº§ã«ç¢ºèªã§ããããã«ãã¦ããã¨ããã¨æãã¾ãã
ãã¾ã
ã¨ãããã¨ã§MEFãMetro ã¹ã¿ã¤ã«ã¢ããªã§ã使ããã¨ãããããã¨ãããã¨ã§è²ã 試ããã¨ãã¦ããCompositionContaienrã¯ã©ã¹ããªãï¼ã©ããªã£ã¦ããã ï¼ï¼ã¨ãã£ã¦è²ã 試ããã¨ããã¨ãã®åä½ãã¹ãã³ã¼ãã以ä¸ã®ãããªæãã§ãã
namespace UnitTestProject1 { using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition.Registration; using System.Reflection; using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class UnitTest1 { [Import] public GreeterClient Client { get; set; } [TestCleanup] public void TearDown() { this.Client = null; } [TestMethod] public void TestMethod1() { // MEF2ã§ã¯å±æ§ãªãã§ãExport Importã§ãã var builder = new RegistrationBuilder(); builder .ForType<Greeter>() .Export(); builder .ForType<GreeterClient>() .ImportProperty( p => p.Greeter, config => config.AsContractType<Greeter>()) .Export(); var catalog = new AssemblyCatalog( typeof(UnitTest1).GetTypeInfo().Assembly, builder); // ã«ã¿ãã°ããCompositionServiceã¨ããã®ãä½ãããã var service = catalog.CreateCompositionService(); // ããã¦Import Assert.IsNull(this.Client); service.SatisfyImportsOnce(this); Assert.IsNotNull(this.Client); // çµæç¢ºèª Assert.AreEqual("Hello world Metro!!", this.Client.Execute()); } } public class GreeterClient { public Greeter Greeter { get; set; } public string Execute() { return this.Greeter.Greet() + " Metro!!"; } } public class Greeter { public string Greet() { return "Hello world"; } } }
ã³ã³ãããªããªã£ã¦ãã¾ãã®ããªã»ã»ã»ã