Esempio n. 1
0
        public void GetInstrument_WithId1_ReturnsFirst_ElementsHaveSameId()
        {
            var data = new List <Instrument>
            {
                new Instrument
                {
                    Id       = 1,
                    Name     = "test1",
                    IsActive = false
                },
                new Instrument
                {
                    Id       = 1,
                    Name     = "test2",
                    IsActive = false
                }
            };

            var mockSet     = new MoqDbSet <Instrument>(data);
            var mockContext = new MoqContext <Instrument>(mockSet, m => m.Instruments);

            var service = new InstrumentsService(mockContext.Object);

            Assert.AreEqual("test1", service.GetInstrument(1).Name);
        }
Esempio n. 2
0
        public void GetInstrument_WithId1_ReturnsNull_IfDbSetIsEmpty()
        {
            var mockSet     = new MoqDbSet <Instrument>();
            var mockContext = new MoqContext <Instrument>(mockSet, m => m.Instruments);

            var service = new InstrumentsService(mockContext.Object);

            Assert.AreEqual(null, service.GetInstrument(1));
        }
Esempio n. 3
0
        public void GetTarget_WithId2_ReturnsNull_ElementDoesNotExist()
        {
            var data = new List <Instrument>
            {
                new Instrument
                {
                    Id       = 1,
                    Name     = "test1",
                    IsActive = false
                }
            };

            var mockSet     = new MoqDbSet <Instrument>(data);
            var mockContext = new MoqContext <Instrument>(mockSet, m => m.Instruments);

            var service = new InstrumentsService(mockContext.Object);

            Assert.AreEqual(null, service.GetInstrument(2));
        }
Esempio n. 4
0
        public void GetInstrument_WithId1_ReturnsTarget_ElementExists()
        {
            var data = new List <Instrument>
            {
                new Instrument
                {
                    Id       = 1,
                    Name     = "test1",
                    IsActive = false
                }
            };

            var mockSet     = new MoqDbSet <Instrument>(data);
            var mockContext = new MoqContext <Instrument>(mockSet, m => m.Instruments);

            var service = new InstrumentsService(mockContext.Object);

            Assert.AreEqual(1, service.GetInstrument(1).Id);
        }