Mock An Interface Property With JustMock In Program?

Jun 6, 2011

I am using JustMock to mock interfaces for unit testing, but perhaps I'm not doing it right.[code]...

I want to mock this interface and set that property so that it can be read by consumers of the interface.Beginning with[code]...

View 1 Replies


ADVERTISEMENT

Mvc - MOQ: Can't Cast Moq.Mock To Interface In .Net

Nov 3, 2010

i am writing a simple unit test to check if the proper view name is being returned by an ActionResult in VB.Net MVC 1. The controller requires a service and I am trying to Mock the service but keep getting this error.Unable to cast object of type 'Moq.Mock`1[SRE.Web.Mvc.INotificationService]' to type 'SRE.Web.Mvc.INotificationService'.As I said, the simple and im not sure where to go from here.

<Test()> _
Public Sub Index_Properly_Validates_Email_Address()
'Arrange
Dim fakeNotifcationService As New Mock(Of INotificationService)(MockBehavior.Strict)

[code]....

View 2 Replies

Visual Studio 2008 - Using Rhino Mocks' Expect.Call For A Mock Property In .NET?

Jun 22, 2011

The following C# code works just fine and the test passes as expected.

using NUnit.Framework;
using Rhino.Mocks;
namespace RhinoMocksTesting
{
public interface ITesting

[Code]...

The Expect.Call line produces the following build error: "Overload resolution failed because no accessible 'Expect' accepts this number of arguments." What is the proper way to use Expect.Call with a mocked property in VB.NET? I've seen a couple posts that say Rhino Mocks works better in VB10, but I'm stuck with Visual Studio 2008 for this current project.

View 1 Replies

"Expected Invocation On The Mock At Least Once But Was Never Performed" Error When Setting Up The Mock

Oct 26, 2011

I'm getting this error from Moq via NUnit, and it doesn't make much in the way of sense to me. "Expected invocation on the mock at least once, but was never performed: x => x.DeleteItem(.$VB$Local_item)"

[Code]...

View 1 Replies

.net - 'Property' Cannot Implement 'Property' Because There Is No Matching Property On Interface 'IName'?

Dec 9, 2011

I'm having some very weird issues with interfaces right now.

I have a very simple setup. In one of my class, I have a Property implementing a Property from an Interface.

In my class it's like:

Private _oForm As IForm
Public Property Form As IForm Implements IContainer.Form
Set(value As IForm)

[Code]...

I have like dozens of interfaces like this working throughout my project and I can't believe this simple one can't work!

View 1 Replies

.net - If An Interface Defines A ReadOnly Property, How Can An Implementer Provide The Setter To This Property

Jun 10, 2011

Is there a way for implementers of an interface where a ReadOnly property is defined to make it a complete Read/Write Property ?

Imagine I define an interface to provide a ReadOnly Property (i.e., just a getter for a given value) :

Interface SomeInterface
'the interface only say that implementers must provide a value for reading
ReadOnly Property PublicProperty As String
End Interface

This means implementers must commit to providing a value. But I would like a given implementer to also allow setting that value. In my head, this would mean providing the Property's setter as part of the implementation, doing something like this :

Public Property PublicProperty As String Implements SomeInterface.PublicProperty
Get
Return _myProperty

[code]....

View 5 Replies

Declare A Property As An Interface Collection Of An Interface?

Feb 7, 2011

I want to declare a property as an interface collection of an interface, and I want to instanciate the explicit type later, in the constructor. Something like this.

Public Class LicenseFile
Implements ILicenseFile
Public Property Collection As IList(Of ILicenseFileDataNode)

[Code]....

In short, the question is "Why It Didn't work"? This is a simplified scenario, but It's easy to take a workarround, But I need understand the reason because It's fails.

View 2 Replies

ASP.NET UI Control As Property In Interface

Aug 3, 2011

I have a number of pages which implement the same interface:[code]The function doSomethingToTextBox takes a textBox item as a parameter and performs some action on it.I know the textBox is contained on every page which implements my interface, and that it has the same name on each page.My question is: how can I declare the textBox as an interface property? This will remove the need to pass the textBox as a parameter to doSomethingToTextBox()I must also add that I'm currently accessing the TextBox using get/set methods defined as part of the interface - I don't want to have to implement these methods for each page as they are exactly the same on each page.

View 1 Replies

Property Not A Member Of Interface?

Jul 8, 2009

I have an Interface defined like this:

Public Interface ISegment
''' <value>
''' The offset where the span begins
'''</value>

[code]....

The problem is that when I try to use the interface in another class, it tells me that Offset and Length are not members of ISegment. Clearly they are. Here is the code that uses the interface

Public Sub UpdateSegmentListOnDocumentChange(Of ISegment)(ByVal list As List(Of ISegment), ByVal e As DocumentEventArgs) Implements IDocument.UpdateSegmentListOnDocumentChange

[code]....

View 7 Replies

C# - Protected Set For A Property Defined In An Interface

Mar 2, 2010

We have an interface, which can be grossly simplified as:

[Code]...

View 3 Replies

Get The Actual Property Name When Referencing An Interface?

Oct 29, 2010

Consider the following case:

Public Interface IHasDateUpdated
Property DateUpdated As DateTime
End Interface
Public Class MyClass

[code]....

Now, assuming I was referencing an instance of MyClass as an IHasDateUpdated; how would I determine the actual name of the property that implements the interface property via reflection?For example:

Dim x As IHasDateUpdated = New MyClass()

' How do I derive "MyDateUpdated" from "x" using x.DateUpdated?

View 1 Replies

How To Check If A Property Type Is An Interface

Feb 12, 2009

I would like to check if a property's type is an interface (not a specific interface, but any interface).

dim __PropertyInfo As PropertyInfo
dim b as boolean = isinterface(__PropertyInfo)

[code].....

View 3 Replies

Implementing An Interface With A Different Property Type?

Mar 1, 2010

I'm currently trying to create a class that is a composition of the SqlDataAdapter class (as unfortunately you can't inherit from it). In order to try and make it as similar as possible I'm using all the same inherits and interfaces as is documented on MSDN.The problem that I am having is that there are some properties where the interface specifies that the type of the property is IDbCommand. But in the SqlDataAdapter the property type is SqlCommand.

View 3 Replies

Optional Readonly Property In Interface

Aug 25, 2009

I am trying to develop a simple interface for allowing quick lists to be generated from classes. Basically, the interface needs to return an ID and a Name. However, some classes have a calculated name property which is read only, others just use a read/write name property. Basically, all I care is that it has a getter, it does not matter if the property has a setter. How can I write this interface to handle either or without throwing compile errors?

View 1 Replies

Interface And Graphics :: Combo Box Text Property?

Apr 9, 2009

I have a vb2008 combo box with the DropDownStyle property set to DropDownList.Now, when I set the text property to something programatically nothing happens. That is, the "something" doesn't show up on the control with list collapsed. It still doesn't show even if I force an update(If DropDownStyle property is set to DropDown, setting the text property programatically works fine, even without forcing an update).

View 4 Replies

VS 2008 - ReadOnly Property Name For Interface Specifiers

Jul 9, 2009

I have the following
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Linq
Imports System.Windows.Forms
[Code] .....

But I am getting this error:
Error1Class 'DemoPlugInTwo' must implement 'ReadOnly Property name() As String' for interface 'Interfaces.IPlugins'. Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers.C:Documents and SettingsOwnerMy DocumentsVisual Studio 2008ProjectsDemoPlugInThreeDemoPlugInThreeDemoPlugInThree.vb1420DemoPlugInThree
I am getting similar errors for the other property and method. I have them set as read only.

View 4 Replies

Interface And Graphics :: Change The Backcolor Property Of An Object To A Rgb Value?

Dec 8, 2004

How can i change the backcolor property of an object to an rgb value?

i do as it says in the help:

Code:
dim ink as long
ink = rgb(233,126,190)
lblInkPot.BackColor = ink

but i get the error "Value of type "Long" cannot be converted to "system.drawing.color"", but it specifically tells you in help to use "long"...

View 4 Replies

Could Not Run Unit Test With Mock

Apr 18, 2012

I tried to make an unit test for this method which is pretty simple only add an object into the data base and if it works well returns true

[Code]...

View 1 Replies

Error: Interface 'System.Web.Mvc.IValueProvider' Cannot Be Indexed Because It Has No Default Property

Nov 19, 2009

This used to work.

<AcceptVerbs(HttpVerbs.Post)> _
Function Widget(ByVal collection As FormCollection) As ActionResult
...
If ... Then

[code]....

I upgraded to ASP.NET MVC 2 Beta and ASP.NET MVC 2 Futures Assembly for Beta and now ToValueProvider() fails with this compile-time error: Interface 'System.Web.Mvc.IValueProvider' cannot be indexed because it has no default property How do I use ModelState.SetModelValue() if not with collection.ToValueProvider()?

View 3 Replies

Interface And Graphics :: Full Item Selection Listview (not The Property One)?

Jan 6, 2010

I already have one year experienced in c++, and built many private applications.My question is simple to ask, and simple to answer I think.When I select an item in a listview, I want the full item to be selected. Now only the TEXT in the listview item is selected. I've made a picture to clearify my problem.The picture in the link below is splitted up in two pictures. It shows what I currently have, and what I want (my aim)

View 4 Replies

Creating A Mock Configuration Setup?

Nov 29, 2011

The program I am building requires a lot of initial user input. I was wanting to stream line this by creating a 'config' file so to speak that after the user enters all the initial data they can click a button that will save their entries into a secure file. When they leave for the day and come back they can click the load button and it auto fills in all the relevant data that will be stored in the file.

Still digging through the MSDN for help, but no luck on options yet.

I was thinking save the information to a text file somehow, but passwords will be stored and I would like to make it secure if possible.

View 7 Replies

How To Mock Method Of A Class Under Test With MOQ

Sep 15, 2011

I have a service class that i want to unit test. The service calls a repository class method in order to save some data. But before I call the save method, I have a validate method that belongs to the service class under test which validates the properies of the class to be persisted as a parameter to the repository save method.I know that to verify that the repository save method is called, i have to mock the repository class and set up the save method, but how do i verify that the validate method belonging to the service class under test is called when unit testing the method under test since they belong to the same class?

View 2 Replies

Interface And Graphics :: Possibility To Get In Program Information From A Called Program?

Aug 7, 2011

Is there a possibillity to get in a vb program information from a called vb program?For example: Dim id As Integer = Shell("C:program.exe id_1") program.exe is a vb windows form program and must return a value back.

View 1 Replies

Creating Get/Set Properties For Interfaces And Using Them In Mock Objects?

Jan 19, 2009

I am having trouble assigning values to the properties defined in the mock objects.

Public Interface IAddCustomerView
Property FirstName() As String
Property LastName() As String
Property Message() As String
End Interface

My unit test below always fails saying that getMessage was never called:

<Test()> _
Public Sub Should_Display_A_Success_Message()
_presenter = New AddCustomerPresenter(_view, _repositoryStub)

[code]....

View 1 Replies

Partial Mock Of A Class With Private Constructor

Sep 9, 2011

I am trying to write some unit tests on a class that looks like this, using Moq [code] the parameterized constructor is private or internal one of the two methods relies on the result of the other.I want to check that when GetThisOrThat is called with a value, it actually calls GetThis. But I also want to mock GetThis so that it returns a specific well-known value.To me this is an example of Partial Mocking, where we create a Mock based on a class, passing the parameters for the constructor. The problem here is that there is no public constructor, and therefore, Moq can not call it..I tried using the Accessors generated by Visual Studio for MSTest, and use those accessors for the mocking, and this is what I came up with [code]

View 1 Replies

Create A Mock API For Third Party Library In Statically Typed Language?

Dec 30, 2009

I have an application in VB/C# .NET which needs to interact with a third party API, but I would like to interface it out so I can use a mock API for testing purposes.[code]...

View 2 Replies

Interface Between Program And Usb?

Feb 24, 2010

Actually i am a new user for this software, so i am seeking some helps from you guys to assist me in my project. My problem is i dont know how to interface between visual basic(studio 2008) with usb cable.

View 1 Replies

Get Program To Interface With A Database?

Mar 8, 2011

for my A2 computing project, I need to get my program to interface with a database. Now I'm having a problem in updating records on the database. Here's what I've got so far.

Sub LockProgram()
'this updates the program to be locked, to prevent peoples trying to force their way in.
'it is simply some basic validation and an update statement on the database
If loginAttemptsToday >= 5 Then

[code]....

My program will read from a database perfectly, it will delete and add rows, but it simply will not update?

View 5 Replies

Implement Program 6 Interface?

Jul 16, 2009

I have an interface program written in VB .Net (VS2008xxx.dll). Is it possible to implement the Interface in a VB6 program (VB6xxx.exe)?

View 8 Replies

Program To An Interface Instead Of Implementation?

Dec 25, 2009

I have been reading about design patterns and application architecture and im told that I should program to an interface instead of implementation. This i understand. So I figured I would start with something small. Never programmed with an interface before. So I want to create an encryption program that will allow the user to select which method to encrypt it with, AES, DPAPI, etc. I started designing the Interface but I am unsure if I am doing this right. [Code] Also, when it comes to the DPAPI implementation, how is the client supposed to supply the Protection Scope? I didn't think this should be in the interface as it only applys to the DPAPI.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved