configuration/tests/When_LoadingConfigWithLifet...

47 строки
1.5 KiB
C#
Исходник Постоянная ссылка Обычный вид История

2018-09-28 02:25:10 +03:00

2017-10-06 07:37:30 +03:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity.Configuration.Tests.ConfigFiles;
using Microsoft.Practices.Unity.TestSupport.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.Practices.Unity.Configuration.Tests
{
/// <summary>
/// Summary description for When_LoadingConfigWithLifetimes
/// </summary>
[TestClass]
public class When_LoadingConfigWithLifetimes : SectionLoadingFixture<ConfigFileLocator>
{
public When_LoadingConfigWithLifetimes()
: base("Lifetimes")
{
}
[TestMethod]
public void Then_ILoggerHasSingletonLifetime()
{
var registration = section.Containers.Default.Registrations.Where(
r => r.TypeName == "ILogger" && r.Name == string.Empty).First();
Assert.AreEqual("singleton", registration.Lifetime.TypeName);
}
[TestMethod]
public void Then_TypeConverterInformationIsProperlyDeserialized()
{
var lifetime = section.Containers.Default.Registrations
.Where(r => r.TypeName == "ILogger" && r.Name == "reverseSession")
.First()
.Lifetime;
Assert.AreEqual("session", lifetime.TypeName);
Assert.AreEqual("backwards", lifetime.Value);
Assert.AreEqual("reversed", lifetime.TypeConverterTypeName);
}
}
}