1

さて、私は単体テストを行っています。今、私は単体テストに不慣れです。私はmvc3フレームワークでnunitとrhinoのモックを使用しています。ApplicationInstaller.cs を単体テストする必要がありますか? nunit テストの推奨される読み取り値をいくつか提案してください。

public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
{
    container.Register(
        AllTypes.FromAssemblyContaining<IEmployeeModelAssembler>()
        .Where(x => x.Name.EndsWith("Assembler"))
        .WithService.DefaultInterfaces());

    container.AddFacility<LoggingFacility>(x => x.LogUsing(LoggerImplementation.Log4net).WithConfig("log4net.config"));

    container.Register(
        // All controllers
        AllTypes.FromAssembly(Assembly.GetExecutingAssembly()).BasedOn<IController>().LifestyleTransient(),
        //
        Component.For<IControllerFactory>().ImplementedBy<IoCControllerFactory>(),
        Component.For<ICookieManager>().ImplementedBy<CookieManager>().LifeStyle.Is(LifestyleType.Transient),
        Component.For<IJsonSerializer>().ImplementedBy<JsonSerializer>(),
        Component.For<ILoanActionsUtility>().ImplementedBy<LoanActionsUtility>(),
        // Default D.I. container
        Component.For<IWindsorContainer>().Instance(container));

    // Register AES web services
    container.Install(new AESServicesBootstrapper.ApplicationInstaller());

}

#endregion

/// <summary>
/// Creates a WCF client for web services passing the token of the authenticated user from the cookie.
/// This method only creates the client / channel, it does not configure the connection settings,
/// those have to be defined by named endpoints on the web.config
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="endPointConfiguration">name of the endpoint on the web.config</param>
/// <returns></returns>

}

4

1 に答える 1

2

私の経験では、上記のコードをテストする価値はあまりありません。基本的には、決定を下すことなく構成するため、テストでは、アプリケーションが希望どおりに構成されていることを確認することしかできません。これは基本的に上記のコードの複製です。

インストーラーでロジックが発生している場合は、その周りでいくつかのテストが必要になる場合があります。多くのロジックで手に負えなくなった場合は、そのコードを別のクラスに削除し、インストーラー コードに含めないという領域を検討しています。

これらのタイプの質問で、プログラマーに幸運が訪れるかもしれません。

于 2013-01-16T15:27:24.687 に答える