using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WalkingTec.Mvvm.Core;
using $cns$;
using $vns$;
using $mns$;
using $dns$;
$othernamespace$
namespace $tns$
{
[TestClass]
public class $model$ControllerTest
{
private $model$Controller _controller;
private string _seed;
public $model$ControllerTest()
{
_seed = Guid.NewGuid().ToString();
_controller = MockController.CreateController<$model$Controller>(new DataContext(_seed, DBTypeEnum.Memory), "user");
}
[TestMethod]
public void SearchTest()
{
PartialViewResult rv = (PartialViewResult)_controller.Index();
Assert.IsInstanceOfType(rv.Model, typeof(IBasePagedListVM<TopBasePoco, BaseSearcher>));
string rv2 = _controller.Search((rv.Model as $model$ListVM).Searcher);
Assert.IsTrue(rv2.Contains("\"Code\":200"));
}
[TestMethod]
public void CreateTest()
{
PartialViewResult rv = (PartialViewResult)_controller.Create();
Assert.IsInstanceOfType(rv.Model, typeof($model$VM));
$model$VM vm = rv.Model as $model$VM;
$model$ v = new $model$();
$cpros$
vm.Entity = v;
_controller.Create(vm);
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
var data = context.Set<$model$>().Find(v.ID);
$assert$
Assert.AreEqual(data.CreateBy, "user");
Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
}
}
[TestMethod]
public void EditTest()
{
$model$ v = new $model$();
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
$pros$
context.Set<$model$>().Add(v);
context.SaveChanges();
}
PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString());
Assert.IsInstanceOfType(rv.Model, typeof($model$VM));
$model$VM vm = rv.Model as $model$VM;
vm.Wtm.DC = new DataContext(_seed, DBTypeEnum.Memory);
v = new $model$();
v.ID = vm.Entity.ID;
$epros$
vm.Entity = v;
vm.FC = new Dictionary<string, object>();
$fc$
_controller.Edit(vm);
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
var data = context.Set<$model$>().Find(v.ID);
$eassert$
Assert.AreEqual(data.UpdateBy, "user");
Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
}
}
[TestMethod]
public void DeleteTest()
{
$model$ v = new $model$();
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
$pros$
context.Set<$model$>().Add(v);
context.SaveChanges();
}
PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());
Assert.IsInstanceOfType(rv.Model, typeof($model$VM));
$model$VM vm = rv.Model as $model$VM;
v = new $model$();
v.ID = vm.Entity.ID;
vm.Entity = v;
_controller.Delete(v.ID.ToString(),null);
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
var data = context.Set<$model$>().Find(v.ID);
$del$
}
}
[TestMethod]
public void DetailsTest()
{
$model$ v = new $model$();
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
$pros$
context.Set<$model$>().Add(v);
context.SaveChanges();
}
PartialViewResult rv = (PartialViewResult)_controller.Details(v.ID.ToString());
Assert.IsInstanceOfType(rv.Model, typeof(IBaseCRUDVM<TopBasePoco>));
Assert.AreEqual(v.ID, (rv.Model as IBaseCRUDVM<TopBasePoco>).Entity.GetID());
}
[TestMethod]
public void BatchEditTest()
{
$model$ v1 = new $model$();
$model$ v2 = new $model$();
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
$mpros$
context.Set<$model$>().Add(v1);
context.Set<$model$>().Add(v2);
context.SaveChanges();
}
PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });
Assert.IsInstanceOfType(rv.Model, typeof($model$BatchVM));
$model$BatchVM vm = rv.Model as $model$BatchVM;
vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() };
$linkedpros$
vm.FC = new Dictionary<string, object>();
$linkedfc$
_controller.DoBatchEdit(vm, null);
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
var data1 = context.Set<$model$>().Find(v1.ID);
var data2 = context.Set<$model$>().Find(v2.ID);
$meassert$
Assert.AreEqual(data1.UpdateBy, "user");
Assert.IsTrue(DateTime.Now.Subtract(data1.UpdateTime.Value).Seconds < 10);
Assert.AreEqual(data2.UpdateBy, "user");
Assert.IsTrue(DateTime.Now.Subtract(data2.UpdateTime.Value).Seconds < 10);
}
}
[TestMethod]
public void BatchDeleteTest()
{
$model$ v1 = new $model$();
$model$ v2 = new $model$();
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
$mpros$
context.Set<$model$>().Add(v1);
context.Set<$model$>().Add(v2);
context.SaveChanges();
}
PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });
Assert.IsInstanceOfType(rv.Model, typeof($model$BatchVM));
$model$BatchVM vm = rv.Model as $model$BatchVM;
vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() };
_controller.DoBatchDelete(vm, null);
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{
var data1 = context.Set<$model$>().Find(v1.ID);
var data2 = context.Set<$model$>().Find(v2.ID);
$mdel$
}
}
[TestMethod]
public void ExportTest()
{
PartialViewResult rv = (PartialViewResult)_controller.Index();
Assert.IsInstanceOfType(rv.Model, typeof(IBasePagedListVM<TopBasePoco, BaseSearcher>));
IActionResult rv2 = _controller.ExportExcel(rv.Model as $model$ListVM);
Assert.IsTrue((rv2 as FileContentResult).FileContents.Length > 0);
}
$add$
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是基于.NET6的跨平台物联网网关设计源码,包含1286个文件,其中主要包含548个cs源代码文件,137个js脚本文件,121个gif图片文件等。系统采用了C#、JavaScript、CSS和HTML技术,实现了物联网网关的功能,包括与多种设备和系统的连接。项目结构清晰,代码可读性强,易于理解和维护。
资源推荐
资源详情
资源评论
收起资源包目录
基于.NET6的跨平台物联网网关设计源码 (1287个子文件)
nlog.config 2KB
fwlib32.cs 536KB
ReferenceNodeManager.cs 201KB
CodeGenVM.cs 125KB
BaseImportVM.cs 60KB
DataContext.cs 52KB
OpcUaClientHelper.cs 52KB
DCExtension.cs 49KB
BasePagedListVM.cs 45KB
BaseCRUDVM.cs 45KB
DeviceModBusMaster.cs 44KB
DataTableTagHelper.cs 42KB
WTMContext.cs 40KB
FormUtils.cs 39KB
FrameworkServiceExtension.cs 39KB
DeviceFanuc.cs 37KB
MyMqttClient.cs 35KB
_FrameworkController.cs 34KB
PlcAsynchronous.cs 33KB
DeviceXGB.cs 32KB
DeviceXGK.cs 32KB
DeviceFanuc.cs 30KB
PropertyHelper.cs 29KB
Utils.cs 29KB
20230412061736_IsUpload.Designer.cs 28KB
DataContextModelSnapshot.cs 28KB
20221206143332_EndianType.Designer.cs 28KB
20221012063127_CmdPeriod.Designer.cs 28KB
20220825004835_variableindex.Designer.cs 28KB
20220810063014_mqttClientId.Designer.cs 28KB
20220517053158_changepublish.Designer.cs 28KB
20220413084526_rpclog.Designer.cs 28KB
20220323063908_attribut.Designer.cs 26KB
20220124063657_platforms.Designer.cs 26KB
20211220151947_disperse.Designer.cs 26KB
20211217052811_expression.Designer.cs 26KB
20211209085327_ini.Designer.cs 26KB
PlcSynchronous.cs 24KB
ExpressionVisitors.cs 24KB
20211209085327_ini.cs 24KB
ExcelPropety.cs 21KB
FrameworkFilter.cs 21KB
TypeExtension.cs 19KB
ModbusMaster.cs 19KB
BaseController.cs 19KB
DeviceThread.cs 19KB
AuthConstants.cs 18KB
ListVMExtension.cs 18KB
PagedListExtension.cs 17KB
GridActionExtension.cs 16KB
BaseBatchVM.cs 16KB
FrameworkMenuVM.cs 16KB
ReferenceServer.cs 15KB
DeviceSiemensS7.cs 15KB
DateRange.cs 15KB
SelectorTagHelper.cs 15KB
Struct.cs 14KB
GridColumn.cs 14KB
PLC.cs 14KB
DeviceMelsecMc.cs 14KB
UEditorOptions.cs 14KB
ModbusIpMaster.cs 14KB
Class.cs 13KB
BaseTemplateVM.cs 13KB
MultiUploadTagHelper.cs 13KB
DeviceToledo.cs 13KB
BaseApiController.cs 12KB
FrameworkMenuVM2.cs 12KB
DuplicateInfo.cs 12KB
ImportExcelVM.cs 12KB
UploadTagHelper.cs 12KB
ComboBoxTagHelper.cs 12KB
CodeGenListVM.cs 12KB
LayuiUIService.cs 11KB
DateTimeTagHelper.cs 11KB
PrivilegeFilter.cs 11KB
Configs.cs 11KB
OPCClientWrapper.cs 11KB
GridHeaderExtension.cs 11KB
ExportDevicesSetting.cs 11KB
DataPrivilegeVM.cs 11KB
ModbusTransport.cs 11KB
AccountController.cs 10KB
DeviceVariableListVM.cs 10KB
ModbusSlave.cs 10KB
FrameworkMenuListVM.cs 10KB
PLCHelpers.cs 10KB
IModbusMaster.cs 10KB
DeviceController.cs 10KB
UAServer.cs 10KB
DeviceService.cs 10KB
FanucFocas.cs 9KB
FrameworkUserController.cs 9KB
SearchPanelTagHelper.cs 9KB
TreeContainerTagHelper.cs 8KB
ModbusUtility.cs 8KB
TransferTagHelper.cs 8KB
BaseElementTag.cs 8KB
CheckBoxTagHelper.cs 8KB
ConsoleUtils.cs 8KB
共 1287 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
沐知全栈开发
- 粉丝: 5704
- 资源: 5223
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功