public void DefaultTranslatedInputRepository_RetrieveMappingsForRawInputs_NoMappingsReturnsDefaultMappings() { var mockPlayerPrefsRepoInterface = Substitute.For <IPlayerPrefsRepositoryInterface>(); var expectedRawInputs = new List <RawInput> { new RawInput("Test", EInputType.Button), new RawInput("Test2", EInputType.Analog) }; const string nullString = null; foreach (var expectedRawInput in expectedRawInputs) { mockPlayerPrefsRepoInterface.GetValueForKey(Arg.Is(expectedRawInput.InputName)) .Returns(nullString); } var defaultTranslatedInputRepo = new DefaultTranslatedInputRepository(mockPlayerPrefsRepoInterface); var actualMappings = defaultTranslatedInputRepo.RetrieveMappingsForRawInputs(expectedRawInputs); foreach (var mapping in actualMappings) { Assert.IsTrue(ObjectComparisonExtensions.EqualByPublicProperties(mapping.Value, defaultTranslatedInputRepo.DefaultMappings[mapping.Key])); } }
public void DefaultTranslatedInputRepository_RetrieveMappingsForRawInputs_ReturnsExpectedMappings() { var mockPlayerPrefsRepoInterface = Substitute.For <IPlayerPrefsRepositoryInterface>(); const EInputKey expectedInputKey = EInputKey.Interact; var expectedRawInputs = new List <RawInput> { new RawInput("Test", EInputType.Button), new RawInput("Test2", EInputType.Analog) }; foreach (var expectedRawInput in expectedRawInputs) { mockPlayerPrefsRepoInterface.GetValueForKey(Arg.Any <string>()) .Returns(expectedInputKey.ToString()); } var defaultTranslatedInputRepo = new DefaultTranslatedInputRepository(mockPlayerPrefsRepoInterface); var actualMappings = defaultTranslatedInputRepo.RetrieveMappingsForRawInputs(expectedRawInputs); foreach (var expectedRawInput in expectedRawInputs) { Assert.IsTrue(ObjectComparisonExtensions.EqualByPublicProperties(actualMappings[expectedRawInput], new TranslatedInput(expectedInputKey, expectedRawInput.InputType))); } }
public void DefaultTranslatedInputRepository_RetrieveMappingsForRawInputs_NoRawInputsReturnsDefaultMappings() { var mockPlayerPrefsRepoInterface = Substitute.For <IPlayerPrefsRepositoryInterface>(); var emptyRawInputs = new List <RawInput>(); var defaultTranslatedInputRepo = new DefaultTranslatedInputRepository(mockPlayerPrefsRepoInterface); var actualMappings = defaultTranslatedInputRepo.RetrieveMappingsForRawInputs(emptyRawInputs); foreach (var mapping in actualMappings) { Assert.IsTrue(ObjectComparisonExtensions.EqualByPublicProperties(mapping.Value, defaultTranslatedInputRepo.DefaultMappings[mapping.Key])); } }