﻿using Ploeh.AutoFixture.Xunit;
using Xunit;
using Xunit.Extensions;

namespace BobTheBuilder.Tests
{
    public class BuildFacts
    {
        [Fact]
        public void CreateADynamicInstanceOfTheRequestedType()
        {
            var sut = A.BuilderFor<SampleType>();

            var result = sut.Build();

            Assert.IsAssignableFrom<dynamic>(result);
            Assert.IsAssignableFrom<SampleType>(result);
        }

        [Theory, AutoData]
        public void SetStringStateByName(string expected)
        {
            var sut = A.BuilderFor<SampleType>();

            sut.WithStringProperty(expected);
            var result = sut.Build();

            Assert.Equal(expected, result.StringProperty);
        }
    }
}

﻿using Ploeh.AutoFixture.Xunit;
using Xunit;
using Xunit.Extensions;

namespace BobTheBuilder.Tests
{
    public class BuildFacts
    {
        [Fact]
        public void CreateADynamicInstanceOfTheRequestedType()
        {
            var sut = A.BuilderFor<SampleType>();

            var result = sut.Build();

            Assert.IsAssignableFrom<dynamic>(result);
            Assert.IsAssignableFrom<SampleType>(result);
        }

        [Theory, AutoData]
        public void SetStringStateByName(string expected)
        {
            var sut = A.BuilderFor<SampleType>();

            sut.WithStringProperty(expected);
            SampleType result = sut.Build();

            Assert.Equal(expected, result.StringProperty);
        }
    }
}

Use explicit type to cast back to SampleType.
Use explicit type to cast back to SampleType.

Using var on the `sut.Build()` line will always result in result being of
type `dynamic`, which we don't want. We need to explicitly specify the
type of the `result` variable to fix intellisense and compilation.
