public void TestInitialiseWithoutCustomClassPresent() { ContentNode contentNode = new ContentNode(); ESTrainingAtom atom = buildDefaultAtom(); ESAtomPhysicsInterface physics = contentNode.LocatePhysics(atom); Assert.AreEqual("EyeSkills.ESTrainingDefaultPhysics", physics.GetType().ToString()); //https://www.devjoy.com/blog/unit-testing-events-and-callbacks-in-csharp/ ESTrainingDefaultPhysics physicsConcrete = physics as ESTrainingDefaultPhysics; //physics.Initialise(atom); //Now we overwrite the initialised settings with mocks physics.Atom = atom; //We skip initialisation because it has GameObject dependencies. //Specify a different audio manager so that the ESTrainingAtom can re-route audio to our mock AudioManagerMock audioMock = new AudioManagerMock(); physicsConcrete.audioManager = audioMock; //SubTitlesVisualiserMock visMock = new SubTitlesVisualiserMock(); //physicsConcrete.subsVisualiser = visMock; //VoiceVisualiserMock subsMock = new VoiceVisualiserMock(); //physicsConcrete.voiceVisualiser = subsMock; callbackCompleted = false; physics.Start(TestCallback); Assert.True(callbackCompleted); Assert.AreEqual(audioMock.providedKey, atom.audioFile); //We don't actually initialise these anymore //Assert.True(visMock.called); //Assert.True(subsMock.called); }
public void TestInitialiseWithCustomClassPresent() { ContentNode contentNode = new ContentNode(); ESTrainingAtom atom = buildCustomAtom(); ESAtomPhysicsInterface physics = contentNode.LocatePhysics(atom); physics.Initialise(atom, delegate(bool success){ Assert.True(success); }); //Now we overwrite the initialised settings with mocks Assert.NotNull(physics); Assert.AreEqual("EyeSkills.ESAtomPhysicsTESTINGPHYSICS", physics.GetType().ToString()); }