public void SetupForTests() { _recordedEvents = new List <string>(); _mockPrefabHandler = Substitute.For <IPrefabHandler>(); _mockSpriteHandler = Substitute.For <ISpriteHandler>(); _mockTechTypeHandler = Substitute.For <ITechTypeHandlerInternal>(); _craftDataHandler = Substitute.For <ICraftDataHandler>(); _spawnable = new TestSpawnable(_recordedEvents) { PrefabHandler = _mockPrefabHandler, SpriteHandler = _mockSpriteHandler, TechTypeHandler = _mockTechTypeHandler, CraftDataHandler = _craftDataHandler }; }
public void Patch_EventsInvoked() { // ARRANGE const TechType createdTechType = TechType.Accumulator; IPrefabHandler mockPrefabHandler = Substitute.For <IPrefabHandler>(); ISpriteHandler mockSpriteHandler = Substitute.For <ISpriteHandler>(); ITechTypeHandlerInternal mockTechTypeHandler = Substitute.For <ITechTypeHandlerInternal>(); ICraftDataHandler mockCraftDataHandler = Substitute.For <ICraftDataHandler>(); IKnownTechHandler mockKnownTechHandler = Substitute.For <IKnownTechHandler>(); mockTechTypeHandler .AddTechType(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <bool>()) .Returns(createdTechType); var techData = new TechData(); var pdaItem = new SimpleTestPdaItem { PrefabHandler = mockPrefabHandler, SpriteHandler = mockSpriteHandler, TechTypeHandler = mockTechTypeHandler, CraftDataHandler = mockCraftDataHandler, KnownTechHandler = mockKnownTechHandler, TechDataToReturn = techData, }; // ACT pdaItem.Patch(); // ASSERT mockCraftDataHandler.Received(1).SetTechData(createdTechType, techData); mockCraftDataHandler.Received(1).AddToGroup(TechGroup.Cyclops, TechCategory.Cyclops, createdTechType); mockKnownTechHandler.DidNotReceiveWithAnyArgs(); mockTechTypeHandler.Received(1).AddTechType(Arg.Any <string>(), "classId", "friendlyName", "description", true); }