Example #1
0
        private static void InitData()
        {
            // get dictionary of all avaiable bands and their specification from the web service
            // this is done first so we can use them with the entries data
            ResistorCalculatorService.ResistorCalculatorServiceClient service    = new ResistorCalculatorService.ResistorCalculatorServiceClient();
            Dictionary <int, ResistorCalculatorService.BandDetail>    bandColors = service.GetBandList();
            List <Band> bands = new List <Band>();

            foreach (KeyValuePair <int, ResistorCalculatorService.BandDetail> band in bandColors)
            {
                ResistorCalculatorService.BandDetail bandItem = (ResistorCalculatorService.BandDetail)band.Value;
                Band bandColor = new Band(band.Key, bandItem);
                bands.Add(bandColor);
            }

            // get dictionary of all avaiable bands and their specification from the web service
            Dictionary <int, ResistorCalculatorService.EntryDetail> entryList = service.GetEntryList();
            List <Entry> entries = new List <Entry>();

            foreach (KeyValuePair <int, ResistorCalculatorService.EntryDetail> entry in entryList)
            {
                ResistorCalculatorService.EntryDetail entryItem = (ResistorCalculatorService.EntryDetail)entry.Value;
                Entry entryData = new Entry(entryItem.ID, entryItem);
                entries.Add(entryData);
            }

            // set the static lists
            Bands   = bands;
            Entries = entries;
        }
Example #2
0
        public void SaveEntryList()
        {
            // Arrange
            ResistorCalculatorService.ResistorCalculatorServiceClient service = new ResistorCalculatorService.ResistorCalculatorServiceClient();

            // Act
            // get the original entry list
            Dictionary <int, ResistorCalculatorService.EntryDetail> entryList = service.GetEntryList();

            // build an new list of just the entry detail adn save back to service
            List <ResistorCalculatorService.EntryDetail> entries = new List <ResistorCalculatorService.EntryDetail>();

            foreach (KeyValuePair <int, ResistorCalculatorService.EntryDetail> entry in entryList)
            {
                ResistorCalculatorService.EntryDetail entryDetail = entry.Value;
                entries.Add(entryDetail);
            }
            service.SaveEntryList(entries.ToArray());

            // get the updated entry list post save to service
            Dictionary <int, ResistorCalculatorService.EntryDetail> entryList2 = service.GetEntryList();

            // Assert
            Assert.AreEqual(entryList.Count, entryList2.Count);
        }
Example #3
0
 // fully qualified constructor for easily creating entries.
 public Entry(int id, DateTime date, int bandColor1, int bandColor2, int bandColor3, int bandColor4, string resistance, string notes = null)
 {
     ID = id;
     ResistorCalculatorService.EntryDetail entryData = new ResistorCalculatorService.EntryDetail();
     entryData.Date         = date;
     entryData.BandColor1ID = bandColor1;
     entryData.BandColor2ID = bandColor2;
     entryData.BandColor3ID = bandColor3;
     entryData.BandColor4ID = bandColor4;
     entryData.Resistance   = resistance;
     entryData.Notes        = notes;
     EntryData = entryData;
 }
Example #4
0
 // enrty detail object based constructor for easily creating entries.
 public Entry(int id, ResistorCalculatorService.EntryDetail entryData)
 {
     ID        = id;
     EntryData = entryData;
 }