Esempio n. 1
0
        public void IndexActionModelIsComplete()
        {
            // Arrange
            var controller = new HomeController();

            //Product[] products = new Product[]  {
            //    new Product { Name = "XBoxSeriesX", Price = 499M },
            //    new Product { Name = "XBoxSeriesS", Price = 299M}
            //};
            Product[] testData = new Product[] {
                new Product {
                    Name = "P1", Price = 75.10M
                },
                new Product {
                    Name = "P2", Price = 120M
                },
                new Product {
                    Name = "P3", Price = 110M
                }
            };
            IDataSource data = new FakeDataSource(testData);

            controller.dataSource = data;
            // Act
            var model = (controller.Index() as ViewResult)?.ViewData.Model
                        as IEnumerable <Product>;

            // Assert
            Assert.Equal(data.Products, model,
                         Comparer.Get <Product>((p1, p2) => p1.Name == p2.Name &&
                                                p1.Price == p2.Price));
        }
        public void Count_WhenCountIsNotSet_ThrowsException()
        {
            FakeDataSource fakeDataSource = new FakeDataSource();

            Action act = () => { fakeDataSource.Count(); };

            act.ShouldThrow<NotImplementedException>();
        }
        public void Skip_SetsItemCountToSkip()
        {
            FakeDataSource fakeDataSource = new FakeDataSource();

            fakeDataSource.Skip(10);

            fakeDataSource.SkippedItemCount.Should().Be(10);
        }
        public void CreateSitemapWithConfiguration_HttpContextIsNull_ThrowsException()
        {
            FakeDataSource dataSource = new FakeDataSource();

            Action act = () => _sitemapProvider.CreateSitemap(null, dataSource, _config.Object);

            act.ShouldThrow<ArgumentNullException>();
        }
        public void Take_TakesItemCountToTake()
        {
            FakeDataSource fakeDataSource = new FakeDataSource();

            fakeDataSource.Take(12);

            fakeDataSource.TakenItemCount.Should().Be(12);
        }
Esempio n. 6
0
        public void Init()
        {
            var db          = new FakeDataSource();
            var testRecords = ObjectMother.ReturnPhotoDataRecord(3);

            testRecords.ForEach(r => db.Photos.Add(r));
            db.SaveChanges();
            target         = new PhotosController(db, provider);
            target.context = new FakeHttpContext();
        }
        public void CreateSitemapWithConfiguration_AsksForSpecificPage_CreatesSitemap()
        {
            FakeDataSource datas = new FakeDataSource(CreateMany<SampleData>()).WithCount(5);

            _config.Setup(item => item.Size).Returns(2);
            _config.Setup(item => item.CurrentPage).Returns(2);
            _config.Setup(item => item.CreateNode(It.IsAny<SampleData>())).Returns(new SitemapNode());
            _actionResultFactory.Setup(item => item.CreateSitemapResult(_httpContext.Object, It.IsAny<SitemapModel>())).Returns(_expectedResult);

            ActionResult result = _sitemapProvider.CreateSitemap(_httpContext.Object, datas, _config.Object);

            result.Should().Be(_expectedResult);
            datas.TakenItemCount.Should().Be(2);
            datas.SkippedItemCount.Should().Be(2);
        }
        public void CreateSitemapWithConfiguration_NodeCountIsGreaterThanPageSize_CreatesIndex(int? currentPage)
        {
            FakeDataSource datas = new FakeDataSource().WithCount(5).WithEnumerationDisabled();
            _config.Setup(item => item.Size).Returns(2);
            _config.Setup(item => item.CurrentPage).Returns(currentPage);
            _config.Setup(item => item.CreateSitemapUrl(It.Is<int>(i => i <= 3))).Returns(string.Empty);

            Expression<Func<SitemapIndexModel, bool>> validateIndex = index => index.Nodes.Count == 3;
            _actionResultFactory.Setup(item => item.CreateSitemapResult(_httpContext.Object, It.Is(validateIndex))).Returns(_expectedResult);

            ActionResult result = _sitemapProvider.CreateSitemap(_httpContext.Object, datas, _config.Object);

            result.Should().Be(_expectedResult);
            datas.SkippedItemCount.Should().NotHaveValue();
            datas.TakenItemCount.Should().NotHaveValue();
        }
Esempio n. 9
0
 // Start is called before the first frame update
 void Start()
 {
     //Sets up both the fake data source and the real data from the ardiuno
     fakeSource       = new FakeDataSource("CLT Composite Beams Board1 2by10 Panel 1.ASC", 200);
     serialDataSource = new SerialDataSource("Com3", new string[] {
         "DASYLab - V 11.00.00",
         "Worksheet name: 6by10beamlayout",
         "Recording date: 7 / 1 / 2016,  4:52:39 PM",
         "Block length: 2",
         "Delta: 1.0 sec.",
         "Number of channels: 3",
         "Date;Measurement time[hh:mm:ss];voltage [V];voltage2 [V]; volage3 [V];"
     });
     MainCollection = new Parser(serialDataSource);
     MainCollection.start();
 }
Esempio n. 10
0
 /// <summary>
 /// 查询ET清洗后的数据
 /// </summary>
 /// <param name="structId">结构物编号</param>
 /// <param name="roundNum">采集轮数</param>
 /// <returns>数据</returns>
 public static DataTable GetETData(int structId, DateTime time)
 {
     return(FakeDataSource.GetETData(structId, time));
 }
        public void CreateSitemapWithConfiguration_PageSizeIsBiggerThanNodeCount_CreatesSitemap()
        {
            var sitemapNodes = new FakeDataSource(CreateMany<SampleData>()).WithCount(1);
            _config.Setup(item => item.Size).Returns(5);

            _config.Setup(item => item.CreateNode(It.IsAny<SampleData>())).Returns(new SitemapNode());
            _actionResultFactory.Setup(item => item.CreateSitemapResult(_httpContext.Object, It.IsAny<SitemapModel>())).Returns(_expectedResult);

            ActionResult result = _sitemapProvider.CreateSitemap(_httpContext.Object, sitemapNodes, _config.Object);

            result.Should().Be(_expectedResult);
            sitemapNodes.TakenItemCount.Should().NotHaveValue();
            sitemapNodes.SkippedItemCount.Should().NotHaveValue();
        }
        public void Count_WhenCountIsSet_ReturnsCount()
        {
            FakeDataSource fakeDataSource = new FakeDataSource().WithCount(7);

            fakeDataSource.Count().Should().Be(7);
        }
Esempio n. 13
0
 /// <summary>
 /// 查询算法配置
 /// </summary>
 /// <param name="sensors">传感器数组</param>
 /// <returns>算法配置</returns>
 public static DataTable GetArithmeticConfig(int[] sensors)
 {
     return(FakeDataSource.GetArithmeticConfig(sensors));
 }
 private FakeDataSource CreateFakeDataSource()
 {
     FakeDataSource fakeDataSource = new FakeDataSource();
     sitemapIndexConfiguration.Setup(configuration => configuration.DataSource).Returns(fakeDataSource);
     return fakeDataSource;
 }
Esempio n. 15
0
 /// <summary>
 /// 保存二次计算后的数据
 /// </summary>
 /// <param name="calcedData">计算后的数据</param>
 public static void SaveCalcedData(DataTable calcedData)
 {
     FakeDataSource.SaveCalcedData(calcedData);
 }
Esempio n. 16
0
 /// <summary>
 /// 查询因异常遗漏未计算的数据
 /// </summary>
 /// <returns>遗漏的数据</returns>
 public static DataTable GetOmitToCalcData()
 {
     return(FakeDataSource.GetOmitToCalcData());
 }
Esempio n. 17
0
 /// <summary>
 /// 查询某传感器一段时间的ET清洗后数据
 /// </summary>
 /// <param name="sensorId">传感器编号</param>
 /// <param name="from">开始时间</param>
 /// <param name="to">结束时间</param>
 /// <returns>数据</returns>
 public static DataTable GetETData(int sensorId, DateTime from, DateTime to)
 {
     return(FakeDataSource.GetETData(sensorId, from, to));
 }
Esempio n. 18
0
 /// <summary>
 /// 查询分组配置
 /// </summary>
 /// <param name="sensors"></param>
 /// <returns></returns>
 public static DataTable GetGroupConfig(int[] sensors)
 {
     return(FakeDataSource.GetGroupConfig(sensors));
 }