Visual Studio for Macで、自分のコードの非表示部分をテストするためのXamarinフォームプロジェクトを参照するTestProjectをMac用にセットアップしました。XamarinユニットがXamarin.Authでポータブルベイトとスイッチエラーをテストしていますか?
私はキーチェーンにアクセスするためにXamarin.Authを活用し、私のコードの一部をテストしようとすると、私は次のエラーを取得していますが。
System.NotImplementedException :
Portable Bait And Switch is nuget feature, so the package must be installed in all project.
NotImplementedException will indicate that Portable Code from PCL is used and not Platform Specific
implementation. Please check whether platform specific Assembly is properly installed.
Cannot save account in Portable profile - bait-and-switch error.
Please file a bug in https://bugzilla.xamarin.com
このコードは、iOSシミュレータ上で正常に実行を動作し、私はそれがxamarinの認証は、このテストプロジェクトに存在しないIOSのキーチェーンを活用方法とは何かを持っていると仮定します。リファレンスにiosのソリューションを追加しようとしましたが、テストプロジェクトの「リファレンスの編集」ではできません。文句を言わないダイアログプロジェクト参照は、それを許可する:ここで
は私のPCLに失敗しているコードです。
AccountStore store;
store = AccountStore.Create();
どうやらそれはAccountStore.Create(とのトラブルを持っている)
ここでは、PCLを呼び出すtestcodeクラスです:ベイト
using System;
using NUnit.Framework;
using CrowdWisdom;
using CrowdWisdom.Authentication;
namespace CrowdWisdomTest
{
[TestFixture()]
public class AuthServiceTest
{
[Test()]
public void SaveRestoreSecret()
{
String secret = "ABCD";
AuthService auth = AuthService.GetInstance();
auth.putSecret("MySecret", secret);
Assert.AreEqual(secret, auth.GetSecret("MySecret"));
}
}
}
Xamarin.Authはプラットフォーム固有のAPIを使用しているため、プラットフォーム固有のデバイスランナー(NUnitとxUnitはiOSとAndroidベースのランナーを使用する必要があります。 NONプラットフォームベースのNUnitランナーなしでテストできます。 – SushiHangover