コード例 #1
0
        public void GetPartiesTest()
        {
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            var partyService = new Mock <IService <Models.Party> >();

            partyService.Setup(ps => ps.GetAll()).Returns(GetPartiesFromService());

            var locationService = new Mock <IService <Models.Location> >();

            locationService.Setup(ls => ls.Get(It.IsAny <int>())).Returns(GetLocation1());

            var cityService = new Mock <IService <Models.City> >();

            cityService.Setup(ls => ls.Get(It.IsAny <int>())).Returns(GetCity1());

            var danceService = new Mock <IService <Models.Dance> >();

            // Arrange
            var partyController = new PartyController(partyService.Object, locationService.Object,
                                                      cityService.Object, danceService.Object, mapper);

            // Act
            IEnumerable <PartyResponse> response = partyController.GetParties().Result;

            // Assert
            Assert.Equal(GetPartiesResponse().Count(), response.Count());
        }
コード例 #2
0
        public Form1()
        {
            InitializeComponent();

            JsonData = @"{ 
                        ""parties"": 
                                  [
                                     { ""id"":0, ""name"":""SPD"", ""longname"":""Sozialdemokratische Partei Deutschlands""},
                                     { ""id"":1, ""name"":""CDU"", ""longname"":""Christlich Demokratische Union Deutschlands""},
                                     { ""id"":2, ""name"":""GRÜNE"", ""longname"":""BÜNDNIS 90/DIE GRÜNEN""},
                                     { ""id"":3, ""name"":""FDP"", ""longname"":""Freie Demokratische Partei""},
                                     { ""id"":4, ""name"":""DIE LINKE"", ""longname"":""DIE LINKE""},
                                     { ""id"":5, ""name"":""PIRATEN"", ""longname"":""Piratenpartei Deutschland""},
                                     { ""id"":6, ""name"":""NPD"", ""longname"":""Nationaldemokratische Partei Deutschlands""},
                                     { ""id"":7, ""name"":""Die PARTEI"", ""longname"":""Partei für Arbeit, Rechtsstaat, Tierschutz, Elitenförderung und basisdemokratische Initiative""},
                                     { ""id"":8, ""name"":""RENTNER"", ""longname"":""RENTNER Partei Deutschland""},
                                     { ""id"":9, ""name"":""ÖDP"", ""longname"":""Ökologisch-Demokratische Partei""},
                                     { ""id"":10, ""name"":""AfD"", ""longname"":""Alternative für Deutschland""},
                                     { ""id"":11, ""name"":""HHBL"", ""longname"":""Hamburger Bürger-Liste""},
                                     { ""id"":12, ""name"":""Liberale"", ""longname"":""Neue Liberale""}
                                  ]
                        }";

            PartyList jsonPartyList = JsonConvert.DeserializeObject <PartyList>(JsonData);

            JsonParties = jsonPartyList.getParties();

            partyCtr = new PartyController();
            parties  = partyCtr.GetParties();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: schor1/Wahl-O-Graph
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                PartyController controller = new PartyController();
                parties = controller.GetParties();

                foreach (var party in parties)
                {
                    listBoxParties.Items.Add(party.NameShort);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }