public void ImageRequestChangesSpecifiedIndexToLoadingState() { var initialArray = new ImageBox[] { new ImageBox.Empty(), new ImageBox.Empty(), new ImageBox.Empty(), new ImageBox.Empty(), new ImageBox.Empty() }; var newArray = ModifyImageSlotReducer.ReduceImageRequest(initialArray, new ImageRequestAction(2, "")); Assert.IsInstanceOf <ImageBox.Loading>(newArray[2], "Modified slot was not of type Loading"); }
public void ImageResultDoesntChangeArrayLength() { var initialArray = new ImageBox[] { new ImageBox.Loaded(Texture2D.whiteTexture) }; var newArray = ModifyImageSlotReducer.ReduceClearSlot(initialArray, new ClearImageSlotAction(0)); Assert.AreEqual(initialArray.Length, newArray.Length, "Reducer changed array length"); }
public void ImageRequestDoesntChangeArrayLength() { var initialArray = new ImageBox[] { new ImageBox.Empty() }; var newArray = ModifyImageSlotReducer.ReduceImageRequest(initialArray, new ImageRequestAction(0, "")); Assert.AreEqual(initialArray.Length, newArray.Length, "Reducer changed array length"); }
public void ImageResultChangesSpecifiedIndexToLoadedState() { var initialArray = new ImageBox[] { new ImageBox.Loading(""), new ImageBox.Loading(""), new ImageBox.Loading(""), new ImageBox.Loading(""), new ImageBox.Loading("") }; var newArray = ModifyImageSlotReducer.ReduceImageResult(initialArray, new ImageResultAction(2, Texture2D.whiteTexture)); Assert.IsInstanceOf <ImageBox.Loaded>(newArray[2], "Modified slot was not of type Loaded"); }
public void ImageResultForNonLoadingSlotThrows() { var initialArray = new ImageBox[] { new ImageBox.Empty() }; Assert.Throws <InvalidOperationException>( () => ModifyImageSlotReducer.ReduceClearSlot(initialArray, new ClearImageSlotAction(0)), "Reducer did not throw Argument exception when targeting non Loading slot" ); }
public void InvalidIndexThrows() { var initialArray = new ImageBox[] { new ImageBox.Empty() }; Assert.Throws <IndexOutOfRangeException>( () => ModifyImageSlotReducer.ReduceClearSlot(initialArray, new ClearImageSlotAction(1)), "Reducer did not throw IndexOutOfRangeException when index was out of range" ); }
public void EmptyArrayThrows() { var initialArray = new ImageBox[0]; Assert.Throws <ArgumentException>( () => ModifyImageSlotReducer.ReduceClearSlot(initialArray, new ClearImageSlotAction(0)), "Reducer did not throw ArgumentException when initial array was empty" ); }
public void InvalidIndexThrows() { var initialArray = new ImageBox[] { new ImageBox.Empty() }; Assert.Throws <IndexOutOfRangeException>( () => ModifyImageSlotReducer.ReduceImageResult(initialArray, new ImageResultAction(1, Texture2D.whiteTexture)), "Reducer did not throw IndexOutOfRangeException when index was out of range" ); }
public void EmptyArrayThrows() { var initialArray = new ImageBox[0]; Assert.Throws <ArgumentException>( () => ModifyImageSlotReducer.ReduceImageResult(initialArray, new ImageResultAction(0, Texture2D.whiteTexture)), "Reducer did not throw ArgumentException when initial array was empty" ); }
public void LoadedSlotHasCorrectTexture() { var initialArray = new ImageBox[] { new ImageBox.Loading("") }; var newArray = ModifyImageSlotReducer.ReduceImageResult(initialArray, new ImageResultAction(0, Texture2D.whiteTexture)); var slot = newArray[0] as ImageBox.Loaded; Assert.AreEqual(Texture2D.whiteTexture, slot !.Texture, "Incorrect Texture"); }
public void LoadingSlotHasCorrectURL() { const string url = "Test URL"; var initialArray = new ImageBox[] { new ImageBox.Empty() }; var newArray = ModifyImageSlotReducer.ReduceImageRequest(initialArray, new ImageRequestAction(0, url)); var slot = newArray[0] as ImageBox.Loading; Assert.AreEqual(url, slot !.URL, "Incorrect URL"); }
public void ImageResultChangesSpecifiedIndexToEmptyState() { var initialArray = new ImageBox[] { new ImageBox.Loaded(Texture2D.whiteTexture), new ImageBox.Loaded(Texture2D.whiteTexture), new ImageBox.Loaded(Texture2D.whiteTexture), new ImageBox.Loaded(Texture2D.whiteTexture), new ImageBox.Loaded(Texture2D.whiteTexture) }; var newArray = ModifyImageSlotReducer.ReduceClearSlot(initialArray, new ClearImageSlotAction(2)); Assert.IsInstanceOf <ImageBox.Empty>(newArray[2], "Modified slot was not of type Empty"); }
public void ImageRequestDoesntChangeOtherIndices() { var initialArray = new ImageBox[] { new ImageBox.Empty(), new ImageBox.Empty(), new ImageBox.Empty(), new ImageBox.Empty(), new ImageBox.Empty() }; var newArray = ModifyImageSlotReducer.ReduceImageRequest(initialArray, new ImageRequestAction(2, "")); void CheckIndex(int expectedIndex, int actualIndex) => Assert.AreEqual(initialArray[expectedIndex], newArray[actualIndex], $"Expected initial slot {expectedIndex} to match new slot {expectedIndex}"); CheckIndex(0, 0); CheckIndex(1, 1); CheckIndex(3, 3); CheckIndex(4, 4); }
public void ImageResultDoesntChangeOtherIndices() { var initialArray = new ImageBox[] { new ImageBox.Loaded(Texture2D.whiteTexture), new ImageBox.Loaded(Texture2D.whiteTexture), new ImageBox.Loaded(Texture2D.whiteTexture), new ImageBox.Loaded(Texture2D.whiteTexture), new ImageBox.Loaded(Texture2D.whiteTexture) }; var newArray = ModifyImageSlotReducer.ReduceClearSlot(initialArray, new ClearImageSlotAction(2)); void CheckIndex(int expectedIndex, int actualIndex) => Assert.AreEqual(initialArray[expectedIndex], newArray[actualIndex], $"Expected initial slot {expectedIndex} to match new slot {expectedIndex}"); CheckIndex(0, 0); CheckIndex(1, 1); CheckIndex(3, 3); CheckIndex(4, 4); }