Esempio n. 1
0
        public void AddCDStateTest()
        {
            int oldListSize = data.cdStates.Count;

            CD cd = new CD()
            {
                id    = 1234,
                title = "Nevermind",
                group = "Nirvana"
            };

            CDState cdState = new CDState()
            {
                cd             = cd,
                dateOfPurchase = new DateTimeOffset(new DateTime(2013, 11, 03))
            };

            dataRepository.AddCDState(cdState);
            int newListSize = data.cdStates.Count;

            //check if size of new and old collection is different
            Assert.AreNotEqual(oldListSize, newListSize);

            //check if collection contains added event
            Assert.IsTrue(data.cdStates.Contains(cdState));
        }
Esempio n. 2
0
        public CDRom()
        {
            m_BRAM       = new SaveMemoryBank();
            m_Ram        = new RamBank[32];
            m_CDInserted = false;
            m_ADPCM      = new ADPCM();

            for (int i = 0; i < 32; i++)
            {
                m_Ram[i] = new RamBank();
            }

            m_Playing     = null;
            m_AudioPaused = false;
            m_PlayChunk   = new byte[0x20000];

            m_FadeCurrent = 1.0f;
            m_FadeDown    = false;
            m_FadeUp      = false;
            m_FadeStep    = 0.0f;

            m_DataReady        = false;
            m_DataTransferDone = false;

            m_CDRomState = CDState.RESET;
        }
        public void UpdateCDState(int index, CDState newCDState)
        {
            CDState cdState = data.cdStates[index];

            cdState.cd             = newCDState.cd;
            cdState.dateOfPurchase = newCDState.dateOfPurchase;
        }
Esempio n. 4
0
        public void UpdateCDStateTest()
        {
            int oldListSize = data.cdStates.Count;
            int randomIndex = new Random().Next(0, oldListSize - 1);

            CD cd = new CD()
            {
                id    = 1234,
                title = "Nevermind",
                group = "Nirvana"
            };

            CDState cdState = new CDState()
            {
                cd             = cd,
                dateOfPurchase = new DateTimeOffset(new DateTime(2013, 11, 03))
            };

            dataRepository.UpdateCDState(randomIndex, cdState);
            int newListSize = data.cdStates.Count;

            //check if size of new and old list is the same
            Assert.AreEqual(oldListSize, newListSize);

            //compare properties
            Assert.AreEqual(cdState.cd, data.cdStates[randomIndex].cd);
            Assert.AreEqual(cdState.dateOfPurchase, data.cdStates[randomIndex].dateOfPurchase);
        }
        public void UpdateCDState(int index, CDState cdState)
        {
            int numberOfElements = repository.GetAllCDStates().Count();

            if (numberOfElements > index)
            {
                repository.UpdateCDState(index, cdState);
            }
        }
        public void AddEvent(Customer customer, CDState cdState)
        {
            bool isEventExist = repository.GetAllEvents().Any(e => e.cdState.Equals(cdState) && e.customer.Equals(customer));

            if (!isEventExist)
            {
                Event evt = new Event()
                {
                    customer = customer, cdState = cdState
                };
                repository.AddEvent(evt);
            }
        }
        public void AddEventNegativeTest()
        {
            int oldListSize = data.events.Count;

            CDState  cdState  = dataRepository.GetAllCDStates().ElementAt(0);
            Customer customer = dataRepository.GetAllCustomers().ElementAt(0);

            service.AddEvent(customer, cdState);
            int newListSize = data.events.Count;

            //check if size of new and old collection is different
            Assert.AreEqual(oldListSize, newListSize);
        }
Esempio n. 8
0
        public void DeleteCDStateTest()
        {
            int oldCollectionSize = data.cdStates.Count;
            int randomIndex       = new Random().Next(0, oldCollectionSize - 1);

            CDState removedCDState = data.cdStates[randomIndex];

            dataRepository.DeleteCDState(randomIndex);

            //check if list size is decreased
            Assert.AreNotEqual(oldCollectionSize, data.cdStates.Count);

            //check if object is removed from collection
            Assert.IsFalse(data.cdStates.Contains(removedCDState));
        }
        public void AddEventPositiveTest()
        {
            int oldListSize = data.events.Count;

            CDState  cdState  = dataRepository.GetAllCDStates().ElementAt(0);
            Customer customer = dataRepository.GetAllCustomers().ElementAt(1);

            service.AddEvent(customer, cdState);
            int newListSize = data.events.Count;

            //check if size of new and old collection is different
            Assert.AreNotEqual(oldListSize, newListSize);

            //check if collection contains added event
            Assert.IsTrue(data.events.Any(x => x.customer.Equals(customer) && x.cdState.Equals(cdState)));
        }
Esempio n. 10
0
        public void UpdateEventTest()
        {
            int oldCollectionSize = data.events.Count;
            int randomIndex       = new Random().Next(0, oldCollectionSize - 1);

            CD cd = new CD()
            {
                id    = 1234,
                title = "Nevermind",
                group = "Nirvana"
            };

            CDState cdState = new CDState()
            {
                cd             = cd,
                dateOfPurchase = new DateTimeOffset(new DateTime(2013, 11, 03))
            };

            Customer customer = new Customer()
            {
                name         = "Kamil",
                surname      = "Filipczak",
                emailAddress = "*****@*****.**",
                age          = 51
            };

            Event evt = new Event()
            {
                cdState  = cdState,
                customer = customer
            };

            dataRepository.UpdateEvent(randomIndex, evt);
            int newCollectionSize = data.events.Count;

            //check if number of events is not changed
            Assert.AreEqual(oldCollectionSize, newCollectionSize);

            //check if properties are the same
            Assert.AreEqual(evt.cdState, data.events[randomIndex].cdState);
            Assert.AreEqual(evt.customer, data.events[randomIndex].customer);
        }
Esempio n. 11
0
        public void AddEventTest()
        {
            int oldListSize = data.events.Count;

            CD cd = new CD()
            {
                id    = 1234,
                title = "Nevermind",
                group = "Nirvana"
            };

            CDState cdState = new CDState()
            {
                cd             = cd,
                dateOfPurchase = new DateTimeOffset(new DateTime(2013, 11, 03))
            };

            Customer customer = new Customer()
            {
                name         = "Kamil",
                surname      = "Filipczak",
                emailAddress = "*****@*****.**",
                age          = 51
            };

            Event evt = new Event()
            {
                cdState  = cdState,
                customer = customer
            };

            dataRepository.AddEvent(evt);
            int newListSize = data.events.Count;

            //check if size of new and old collection is different
            Assert.AreNotEqual(oldListSize, newListSize);

            //check if collection contains added event
            Assert.IsTrue(data.events.Contains(evt));
        }
        public override void Fill(DataContext context)
        {
            List <Customer>              customers = context.customers;
            Dictionary <int, CD>         cds       = context.cds;
            ObservableCollection <Event> events    = context.events;
            List <CDState> cdStates = context.cdStates;

            try {
                List <string[]> dataList = File.ReadLines("data.txt").Select(line => line.Split(';')).ToList();

                foreach (string[] line in dataList)
                {
                    Customer cust = new Customer {
                        name = line[0], surname = line[1], emailAddress = line[2], age = Int16.Parse(line[3])
                    };
                    CD cd = new CD {
                        id = Int16.Parse(line[4]), title = line[5], group = line[6]
                    };
                    CDState cdState = new CDState {
                        cd = cd, dateOfPurchase = new DateTimeOffset(new DateTime(Int32.Parse(line[7]), Int32.Parse(line[8]), Int32.Parse(line[9])))
                    };
                    Event evt = new Event {
                        cdState = cdState, customer = cust
                    };

                    customers.Add(cust);
                    cds.Add(cd.id, cd);
                    cdStates.Add(cdState);
                    events.Add(evt);
                }
                Console.Write(customers.Count);
            }
            catch (FileNotFoundException exception) {
                Console.Write(exception.Message);
            }
            catch (IOException exception) {
                Console.Write(exception.StackTrace);
            }
        }
Esempio n. 13
0
        public void WriteCommand(byte data)
        {
            if (m_CDRomState == CDState.RESET)
            {
                switch (data)
                {
                case 0x81:
                    m_CDRomState       = CDState.RESET;
                    m_DataReady        = false;
                    m_DataTransferDone = false;
                    break;

                default:
                    Console.WriteLine("Unknown command {0:x}", data);
                    break;
                }
            }
            else
            {
                // STUFF CD-ROM COMMAND IN
            }
        }
        public void UpdateEventNegativeTest()
        {
            //clear collection
            data.events.Clear();

            CD cd = new CD()
            {
                id    = 1234,
                title = "Nevermind",
                group = "Nirvana"
            };

            CDState cdState = new CDState()
            {
                cd             = cd,
                dateOfPurchase = new DateTimeOffset(new DateTime(2013, 11, 03))
            };

            Customer customer = new Customer()
            {
                name         = "Kamil",
                surname      = "Filipczak",
                emailAddress = "*****@*****.**",
                age          = 51
            };

            Event evt = new Event()
            {
                cdState  = cdState,
                customer = customer
            };

            //try to update empty collection
            service.UpdateEvent(0, evt);

            //check if collection is still empty
            Assert.AreEqual(0, data.events.Count);
        }
        public void UpdateCDStateNegativeTest()
        {
            //clear list
            data.cdStates.Clear();

            CD cd = new CD()
            {
                id    = 1234,
                title = "Nevermind",
                group = "Nirvana"
            };

            CDState cdState = new CDState()
            {
                cd             = cd,
                dateOfPurchase = new DateTimeOffset(new DateTime(2013, 11, 03))
            };

            //try to update empty list
            service.UpdateCDState(0, cdState);

            //check if size of new and old list is the same
            Assert.AreEqual(0, data.cdStates.Count);
        }
Esempio n. 16
0
        public void WriteAt(int address, byte data)
        {
            switch (address & 0xf)
            {
            case 0x00:      // CDC Status Register
                m_CDRomState       = CDState.RESET;
                m_DataReady        = false;
                m_DataTransferDone = false;
                return;

            case 0x01:      // CDC Command / Status / Data
                WriteCommand(data);
                return;

            case 0x02:      // CD CONTROL REGISTER (IRQ mask)
                m_CDControlReg = data;
                return;

            case 0x04:      // CD RESET
                m_CDResetRegister = data;
                if ((data & 0x02) != 0)
                {
                    m_CDRomState = CDState.RESET;
                }
                return;

            case 0x07:      // BRAM ENABLE
                m_BRAM.WriteProtect((data & 0x80) == 0);
                return;

            case 0x08:      // ADPCM LSB ADDRESS LATCH
                m_ADPCM.SetAddressLo(data);
                return;

            case 0x09:      // ADPCM MSB ADDRESS LATCH
                m_ADPCM.SetAddressHi(data);
                return;

            case 0x0A:      // ADPCM RAM ACCESS REGISTER
                m_ADPCM.WriteData(data);
                return;

            case 0x0B:      // ADPCM DMA CONTROL
                m_ADPCM.WriteDMAControl(data);
                return;

            case 0x0D:      // ADPCM ADDRESS CONTROL
                m_ADPCM.AddressControl(data);
                return;

            case 0x0E:      // ADPCM PLAYBACK RATE
                m_ADPCM.SetPlayRate(data);
                return;

            case 0x0F:      // ADPCM AND CD AUDIO FADER
                switch (data & 0xF)
                {
                case 0x0:
                case 0x1:
                    FadeAudio(false, 1 / (m_PlayFrequency * 2.0f));
                    m_ADPCM.FadeAudio(false, 1 / (m_PlayFrequency * 2.0f));
                    break;

                case 0x8:
                case 0x9:
                    FadeAudio(true, 1 / (m_PlayFrequency * 6.5f));
                    break;

                case 0xA:
                    m_ADPCM.FadeAudio(true, 1 / (m_PlayFrequency * 6.5f));
                    break;

                case 0xC:
                case 0xD:
                    FadeAudio(true, 1 / (m_PlayFrequency * 2.0f));
                    break;

                case 0xE:
                    m_ADPCM.FadeAudio(true, 1 / (m_PlayFrequency * 2.0f));
                    break;
                }
                return;

            // --- READ ONLY REGISTERS

            case 0x03:      // CD STATUS REGISTER
            case 0x0C:      // ADPCM STATUS REGISTER
                return;
            }
            Console.WriteLine("CD-ROM ACCESS {0:X} -> {1:X}", address, data);
        }
Esempio n. 17
0
        public void Stopped()
        {
            State = CDState.Started;
            Timer.Enabled = false;

            TimeChangedEventArgs e = new TimeChangedEventArgs(Time.ToString());
            DelegateExpansion.CrossInvoke(CountDownChanged, this, e);
            //CountDownChanged(this,e) ;
        }
Esempio n. 18
0
        public void Reset()
        {
            State = CDState.NotStarted;
            Enabled = false;
            Time.Clear();

            TimeChangedEventArgs e = new TimeChangedEventArgs(Time.ToString());
            DelegateExpansion.CrossInvoke(CountDownChanged, this, e);
            //CountDownChanged(this,e) ;
        }
        public override void Fill(DataContext context)
        {
            List <Customer>              customers = context.customers;
            Dictionary <int, CD>         cds       = context.cds;
            ObservableCollection <Event> events    = context.events;
            List <CDState> cdStates = context.cdStates;


            Customer c1 = new Customer()
            {
                surname      = "Kowalski",
                name         = "Jan",
                emailAddress = "*****@*****.**",
                age          = 30
            };
            Customer c2 = new Customer()
            {
                surname      = "Nowak",
                name         = "Katarzyna",
                emailAddress = "*****@*****.**",
                age          = 35
            };
            Customer c3 = new Customer()
            {
                surname      = "Miłoch",
                name         = "Krzysztof",
                emailAddress = "*****@*****.**",
                age          = 24
            };


            CD cd1 = new CD()
            {
                id    = 1526,
                title = "Let It Be",
                group = "The Beatles",
            };
            CD cd2 = new CD()
            {
                id    = 2548,
                title = "Bad",
                group = "Michael Jackson",
            };
            CD cd3 = new CD()
            {
                id    = 3789,
                title = "Undercover",
                group = "The Rolling Stones",
            };


            CDState cdState1 = new CDState()
            {
                cd             = cd1,
                dateOfPurchase = new DateTimeOffset(new DateTime(2012, 06, 14))
            };
            CDState cdState2 = new CDState()
            {
                cd             = cd2,
                dateOfPurchase = new DateTimeOffset(new DateTime(2015, 06, 13))
            };
            CDState cdState3 = new CDState()
            {
                cd             = cd3,
                dateOfPurchase = new DateTimeOffset(new DateTime(2018, 02, 11))
            };


            Event e1 = new Event()
            {
                cdState  = cdState1,
                customer = c1
            };
            Event e2 = new Event()
            {
                cdState  = cdState2,
                customer = c2
            };
            Event e3 = new Event()
            {
                cdState  = cdState3,
                customer = c3
            };

            customers.Add(c1);
            customers.Add(c2);
            customers.Add(c3);
            cds.Add(cd1.id, cd1);
            cds.Add(cd2.id, cd2);
            cds.Add(cd3.id, cd3);
            cdStates.Add(cdState1);
            cdStates.Add(cdState2);
            cdStates.Add(cdState3);
            events.Add(e1);
            events.Add(e2);
            events.Add(e3);
        }
 public void AddCDState(CDState cdState)
 {
     data.cdStates.Add(cdState);
 }