public void InsertAsync()
        {
            var panel = CreateRandom();

            int res = _repository.InsertAsync(panel).Result;

            Assert.NotEqual(default(int), panel.Id);

            var r = _repository.Query().Where(p => p.Brand == panel.Brand).FirstOrDefault();

            FullCompare(panel, r);
        }
Ejemplo n.º 2
0
        public async Task InsertAsync()
        {
            var panel = new Panel
            {
                Brand     = "NonEmpty",
                Latitude  = 12,
                Longitude = 123,
                Serial    = "NonEmpty",
            };

            int insertResponse = await _repository.InsertAsync(panel);

            Assert.NotEqual(default(int), panel.Id);

            var getPanelResponse = await _repository.GetAsync(panel.Id);

            Assert.True(getPanelResponse.Latitude == 12);
            Assert.True(getPanelResponse.Longitude == 123);
            Assert.True(getPanelResponse.Brand == "NonEmpty");
            Assert.True(getPanelResponse.Serial == "NonEmpty");
        }
        public void InsertAsync_WorksFine()
        {
            // Arrange
            Mock <CrossSolarDbContext> mock      = new Mock <CrossSolarDbContext>();
            Mock <DbSet <Panel> >      mockDbSet = new Mock <DbSet <Panel> >();

            mock.Setup(a => a.Set <Panel>()).Returns(() => mockDbSet.Object);
            mock.Setup(a => a.SaveChangesAsync(true, CancellationToken.None)).Returns(Task.FromResult(1));

            // Act
            GenericRepository <Panel> genericRepository = new PanelRepository(mock.Object);
            var actual = Record.ExceptionAsync(() => genericRepository.InsertAsync(new Panel()));

            Assert.Null(actual.Result);
        }
Ejemplo n.º 4
0
        public void TestPanelRepository()
        {
            IPanelRepository panelRepository = new PanelRepository(new CrossSolarDbContext());

            var panel = new Panel
            {
                Brand     = "Areva",
                Latitude  = 12.345678,
                Longitude = 98.7655432,
                Serial    = "AAAA1111BBBB27657"
            };

            panelRepository.InsertAsync(panel);

            var result = panelRepository.GetBySerialNumAsync("AAAA1111BBBB27657");

            Assert.NotNull(result);
        }
        public async Task testInsert()
        {
            var panel = new Panel
            {
                Brand     = "Areva",
                Latitude  = 12.345678,
                Longitude = 98.7655432,
                Serial    = "AAAA1111BBBB2222"
            };

            _crossSolarDbContextMock.Setup(m => m.Set <Panel>().Add(panel));

            // Arrange

            // Act
            await _panelRepository.InsertAsync(panel);

            // Assert

            Assert.Equal(typeof(Panel), panel.GetType());
        }