Ejemplo n.º 1
0
            public void WasCalled()
            {
                var sut = new TestXafBuilderManager(A.Fake <ITypesInfo>());

                sut.Build();

                A.CallTo(() => sut.Builder.Build()).MustHaveHappened();
            }
Ejemplo n.º 2
0
        public static void XafBuilderManagerTests() => Describe(nameof(XafBuilderManager), () =>
        {
            It("calls Refresh after Build", () =>
            {
                var typesInfo = A.Fake <ITypesInfo>();

                IBuilderManager builderManager = new XafBuilderManager(typesInfo);
                var builderA = A.Fake <IBuilder>(o => o.Implements <ITypeInfoProvider>());
                var builderB = A.Fake <IBuilder>(o => o.Implements <ITypeInfoProvider>());

                var typeInfoA = A.Fake <ITypeInfo>();
                var typeInfoB = A.Fake <ITypeInfo>();

                A.CallTo(() => ((ITypeInfoProvider)builderA).TypeInfo).Returns(typeInfoA);
                A.CallTo(() => ((ITypeInfoProvider)builderB).TypeInfo).Returns(typeInfoB);

                builderManager
                .Add(builderA)
                .Add(builderB)
                .Build();

                A.CallTo(
                    () => builderA.Build()
                    ).MustHaveHappenedOnceExactly()
                .Then(
                    A.CallTo(() => typesInfo.RefreshInfo(typeInfoA)
                             ).MustHaveHappenedOnceExactly())
                .Then(
                    A.CallTo(() => builderB.Build()
                             ).MustHaveHappenedOnceExactly())
                .Then(
                    A.CallTo(() => typesInfo.RefreshInfo(typeInfoB)
                             ).MustHaveHappenedOnceExactly());
            });

            It("uses GetBuilders overload", () =>
            {
                var sut = new TestXafBuilderManager(A.Fake <ITypesInfo>());

                sut.Build();

                A.CallTo(
                    () => sut.Builder.Build()
                    ).MustHaveHappened();
            });
        });