jeudi 3 décembre 2015

Passing Session in Unit Test

I have writing unit tests for my services.I have used Azure Active Directory for Authentication. Now while passing the sessions using MockHttpRequest i am getting exception as Unable to cast object of type 'ServiceStack.AuthUserSession' to type 'AadAuthSession'.Here is my code in Testbase class.

  IAuthSession session = new AadAuthSession();
        session.UserName = "Author";
        appHost.Plugins.Add(new AuthFeature(() => session,
            new IAuthProvider[] {
                new AadAuthProvider(appHost.AppSettings),
            }
   ));

Am i missing something ..How to cast it correctly ?

Aucun commentaire:

Enregistrer un commentaire