Beispiel #1
0
        public void UpdateMappings_ShouldUpdateWireMockMappings()
        {
            var mappingInfoViewModels = MappingInfoViewModelTestUtils.SomeMappings();

            MockServer.UpdateMappings(mappingInfoViewModels);

            WireMockMappingsShouldBeConfiguredWith(mappingInfoViewModels);
        }
Beispiel #2
0
        public void Constructor_ShouldCallMockServerUpdateMappingsWithLoadedMappings()
        {
            var expectedMappings = MappingInfoViewModelTestUtils.SomeMappings();

            A.CallTo(() => _mappingsProvider.LoadMappings()).Returns(ToPersistableMappings(expectedMappings));

            _mainWindowViewModel = new MainWindowViewModel(_mockServer, _mappingsProvider);

            A.CallTo(() => _mockServer.UpdateMappings(A <IEnumerable <MappingInfoViewModel> > .That.Matches(map => AreEqual(map, expectedMappings)))).MustHaveHappenedOnceExactly();
        }
Beispiel #3
0
        public void WhenMainWindowsViewModelIsInstantiated_Mappings_ShouldReturnTheMappingReturnByMappingsProvider()
        {
            var expectedMappings = MappingInfoViewModelTestUtils.SomeMappings();

            A.CallTo(() => _mappingsProvider.LoadMappings()).Returns(ToPersistableMappings(expectedMappings));

            _mainWindowViewModel = new MainWindowViewModel(_mockServer, _mappingsProvider);

            _mainWindowViewModel.Mappings.Should().BeEquivalentTo(expectedMappings);
        }
Beispiel #4
0
        public void ApplyCommand_ShouldCallMockServerUpdateMappingsAndShouldSaveMappings()
        {
            var expectedMappings = MappingInfoViewModelTestUtils.SomeMappings();

            A.CallTo(() => _mappingsProvider.LoadMappings()).Returns(ToPersistableMappings(expectedMappings));
            _mainWindowViewModel = new MainWindowViewModel(_mockServer, _mappingsProvider);
            Fake.ClearRecordedCalls(_mockServer);

            ExecuteApplyCommand();

            A.CallTo(() => _mockServer.UpdateMappings(_mainWindowViewModel.Mappings)).MustHaveHappenedOnceExactly()
            .Then(A.CallTo(() => _mappingsProvider.SaveMappings(ShouldMatchInfoMappingsViewModel(_mainWindowViewModel.Mappings))).MustHaveHappenedOnceExactly());
        }
Beispiel #5
0
        public void WhenDeletingAMappingLoadedFromDefaultConfiguration_ShouldRemoveThatMapping()
        {
            var mapping1            = MappingInfoViewModelTestUtils.AMapping();
            var mapping2            = MappingInfoViewModelTestUtils.AMapping();
            var mapping3            = MappingInfoViewModelTestUtils.AMapping();
            var persistableMappings = ToPersistableMappings(new List <MappingInfoViewModel> {
                mapping1, mapping2, mapping3
            });

            A.CallTo(() => _mappingsProvider.LoadMappings()).Returns(persistableMappings);
            _mainWindowViewModel = new MainWindowViewModel(_mockServer, _mappingsProvider);
            var refreshedMapping2 = _mainWindowViewModel.Mappings.Single(m => AreEqual(m, mapping2));

            refreshedMapping2.DeleteMappingCommand.Execute(null);

            _mainWindowViewModel.Mappings.Should().BeEquivalentTo(new List <MappingInfoViewModel> {
                mapping1, mapping3
            });
        }