summaryrefslogtreecommitdiff
path: root/spec/unit/infrastructure/logging/LogSpecs.cs
blob: 26b6b7c5f01390e73010c7d100087042cd74311d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using gorilla.infrastructure.container;
using gorilla.infrastructure.logging;
using Machine.Specifications;

namespace specs.unit.infrastructure.logging
{
    [Subject(typeof (Log))]
    public class when_creating_a_logger_for_a_particular_type
    {
        It should_return_the_logger_created_for_that_type = () => result.should_be_equal_to(logger.Object);

        Establish c =
            () =>
            {
                var factory = Create.an<LogFactory>();
                var registry = Create.an<DependencyRegistry>();
                logger = Create.an<Logger>();
                registry.Setup(x => x.get_a<LogFactory>()).Returns(factory.Object);
                factory.Setup(x => x.create_for(typeof (string))).Returns(logger.Object);

                Resolve.initialize_with(registry.Object);
            };

        Because b = () =>
        {
            result = Log.For("mo");
        };

        Cleanup a = () => Resolve.initialize_with(null);

        static Logger result;
        static Moq.Mock<Logger> logger;
    }
}