当我IReadOnlyList在我的代码中实现时,我的单元测试抛出了一个AutoMapperMappingException.
从挖掘文章和文档,我的猜测是AutoMapper需要特殊的readonly类型编码.这会是什么样的?
注意:我尝试Mapper.AssertConfigurationIsValid();了另一篇文章建议,但没有改进.
测试名称:CreateOrder_ValidContract_CreatesNewOrder测试FullName:ACME.Maintenance.Domain.Test.OrderServiceTest.CreateOrder_ValidContract_CreatesNewOrder测试源:C:\ Users\me\documents\visual studio 2015\Projects\ACME.Maintenance\ACME.Maintenance.Domain.Test\OrderServiceTest. cs:第65行测试结果:测试持续时间失败:0:00:00.0233941
结果StackTrace:位于C:\ Users\me\documents\visual studio 2015\Projects\ACME.Maintenance\ACME中ACME.Maintenance.Domain.ContractService.GetById(String contractId)的lambda_method(Closure,ContractDto,Contract,ResolutionContext). Maintenance.Domain\ContractService.cs:位于C:\ Users\me\documents\visual studio 2015\Projects\ACME.Maintenance\ACME.Maintenance.Domain中的ACME.Maintenance.Domain.Test.OrderServiceTest.CreateOrder_ValidContract_CreatesNewOrder()的第34行. Test\OrderServiceTest.cs:第69行结果消息:测试方法ACME.Maintenance.Domain.Test.OrderServiceTest.CreateOrder_ValidContract_CreatesNewOrder引发异常:AutoMapper.AutoMapperMappingException:缺少类型映射配置或不支持的映射.
映射类型:ContractDto - > Contract
ACME.Maintenance.Domain.DTO.ContractDto - > ACME.Maintenance.Domain.Contract
Mapper.Initialize(cfg => cfg.CreateMap<ContractDto, Contract>());
Mapper.Initialize(cfg => cfg.CreateMap<PartDto, Part>());
[TestMethod]
public void CreateOrder_ValidContract_CreatesNewOrder()
{
//Arrange
var orderService = new OrderService();
var contractService = new ContractService(_contractRepository);
var contract = contractService.GetById(ValidContractId);
// Act
var newOrder = orderService.CreateOrder(contract);
// Assert
Assert.IsInstanceOfType(newOrder, typeof(Order));
Guid guidOut;
Assert.IsTrue(Guid.TryParse(newOrder.OrderId, out guidOut));
Assert.AreEqual(newOrder.Status, ContractStatus.New);
Assert.IsInstanceOfType(newOrder.Items, …Run Code Online (Sandbox Code Playgroud) 我正在访问EWS日历中的约会与会者.我试过了:
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End);
但是我的appointments列表条目每个都返回null必需/可选参加者字段,即使多个用户已接受测试约会.我的假设是PropertySet需要包含更多ApplicationSchema属性,如下所示:
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.RequiredAttendees,
AppointmentSchema.OptionalAttendees);
Run Code Online (Sandbox Code Playgroud)
但是,这会在calendar.FindAppointments(cView)上引发以下ServiceValidationException错误:
Microsoft.Exchange.WebServices.Data.ServiceValidationException: 无法在FindItem请求中使用属性RequiredAttendees.
如何修复此问题以appointments包括必需/可选的与会者?
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials(emailAddress, emailPassword);
// Initialize values for the start and end times, and the number of appointments to retrieve.
DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddYears(1);
const int NUM_APPTS = 4;
// Initialize the calendar folder object with only the folder ID.
CalendarFolder calendar = CalendarFolder.Bind(service, …Run Code Online (Sandbox Code Playgroud) 我成功background-position: bottom top 100px地将图像移动到顶部,但是我没有成功将图像向右移动.
是否有类似的东西background-position: bottom top 100px, right 900px可能有助于产生预期的结果?
#AddNewMeetingButton {
position: absolute;
top: 0;
text-align: center;
background-image: url(Images/add_icon_48x48.png);
background-position: bottom top 100px, right 800px;
background-repeat: no-repeat;
height: 190px;
width: 915px;
background-color: transparent;
outline: none;
border: none;
z-index: 2;
}
Run Code Online (Sandbox Code Playgroud) 我写了一个简单的Python函数来生成matplotlib图.我plotData从一个单独的脚本中多次调用,但每次生成一个新的图.我想要的是总是只有一个情节,比如subplot.clear()清除数据变化之间的子图.
我需要一种从外部识别图形的方法,plotData以便我可以清除新数据的图形.实现这一目标的最佳方法是什么?
## Plot Data Function
def plotData(self):
# Setup figure to hold subplots
f = Figure(figsize=(10,8), dpi=100)
# Setup subplots
subplot1=f.add_subplot(2,1,1)
subplot2=f.add_subplot(2,1,2)
# Show plots
dataPlot = FigureCanvasTkAgg(f, master=app)
dataPlot.show()
dataPlot.get_tk_widget().pack(side=RIGHT, fill=BOTH, expand=1)
Run Code Online (Sandbox Code Playgroud)