public void WhenInitialized_ShouldUseTheITransformationCollectionInstanceGiven() { // Arrange var fakeITransformCollection = A.Fake<ITransformationCollection>(); // Act var builder = new MappedTransformationCollectionBuilder(fakeITransformCollection, 500); // Assert Assert.Same(fakeITransformCollection, builder.Transformations); }
public void To_WhenInvoked_ShouldReturnAnInstanceWithTheSameStatusCode() { // Arrange var fakeITransformCollection = A.Fake<ITransformationCollection>(); var builder = new MappedTransformationCollectionBuilder(fakeITransformCollection, 500); // Act var newBuilder = builder.For<Exception>(); // Assert Assert.NotNull(newBuilder); Assert.Equal(500, newBuilder.StatusCode); }
public void WhenInitialized_ShouldNotModifyTheStatusCode() { // Arrange var fakeITransformCollection = A.Fake<ITransformationCollection>(); // Act var builder = new MappedTransformationCollectionBuilder(fakeITransformCollection, 500); // Assert Assert.Equal(500, builder.StatusCode); }
public void To_WhenInvoked_ShouldAddANewTransformationIntoTheCollection() { // Arrange var transformations = new Dictionary<Type, int>(); var fakeITransformCollection = A.Fake<ITransformationCollection>(); A.CallTo(() => fakeITransformCollection.AddMappingFor<Exception>(A<int>._)).Invokes((int sc) => { transformations.Add(typeof(Exception), sc); }); var builder = new MappedTransformationCollectionBuilder(fakeITransformCollection, 500); // Act var newBuilder = builder.For<Exception>(); // Assert A.CallTo(fakeITransformCollection).Where(call => call.Method.Name == "AddMappingFor").MustHaveHappened(Repeated.Exactly.Once); Assert.NotNull(newBuilder); Assert.Equal(1, transformations.Count); Assert.True(transformations.ContainsKey(typeof(Exception))); Assert.Equal(500, transformations[typeof(Exception)]); }