Search Results

Search found 6108 results on 245 pages for 'entry'.

Page 35/245 | < Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >

  • How to allow users to select their own grouping for a .NET TreeView control

    - by Chapso
    I am using a treeview to display projects, tasks, time entries, and the people who are working on a project. I would like to allow the user to define a custom grouping (ie. Project->Task->Time Entries or Project->Date (of time entry)->Task->TimeEntry). The relevant groups would be Project, Task, Time Entry, and Person, with some metadata from them. I want to have some modular way to allow a user to specify how they would like to display the information. Does anyone know of a good method by which this can be done? I currently have hard-coded a display which looks like this: Project Task Time Entry Next Project ... My thought is to do something like write methods to display each type and somehow let a user select what order the display would group. Please let me know if I am not being clear enough.

    Read the article

  • Transaction issue in java with hibernate - latest entries not pulled from database

    - by Gearóid
    Hi, I'm having what seems to be a transactional issue in my application. I'm using Java 1.6 and Hibernate 3.2.5. My application runs a monthly process where it creates billing entries for a every user in the database based on their monthly activity. These billing entries are then used to create Monthly Bill object. The process is: Get users who have activity in the past month Create the relevant billing entries for each user Get the set of billing entries that we've just created Create a Monthly Bill based on these entries Everything works fine until Step 3 above. The Billing Entries are correctly created (I can see them in the database if I add a breakpoint after the Billing Entry creation method), but they are not pulled out of the database. As a result, an incorrect Monthly Bill is generated. If I run the code again (without clearing out the database), new Billing Entries are created and Step 3 pulls out the entries created in the first run (but not the second run). This, to me, is very confusing. My code looks like the following: for (User user : usersWithActivities) { createBillingEntriesForUser(user.getId()); userBillingEntries = getLastMonthsBillingEntriesForUser(user.getId()); createXMLBillForUser(user.getId(), userBillingEntries); } The methods called look like the following: @Transactional public void createBillingEntriesForUser(Long id) { UserManager userManager = ManagerFactory.getUserManager(); User user = userManager.getUser(id); List<AccountEvent> events = getLastMonthsAccountEventsForUser(id); BillingEntry entry = new BillingEntry(); if (null != events) { for (AccountEvent event : events) { if (event.getEventType().equals(EventType.ENABLE)) { Calendar cal = Calendar.getInstance(); Date eventDate = event.getTimestamp(); cal.setTime(eventDate); double startDate = cal.get(Calendar.DATE); double numOfDaysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH); double numberOfDaysInUse = numOfDaysInMonth - startDate; double fractionToCharge = numberOfDaysInUse/numOfDaysInMonth; BigDecimal amount = BigDecimal.valueOf(fractionToCharge * Prices.MONTHLY_COST); amount.scale(); entry.setAmount(amount); entry.setUser(user); entry.setTimestamp(eventDate); userManager.saveOrUpdate(entry); } } } } @Transactional public Collection<BillingEntry> getLastMonthsBillingEntriesForUser(Long id) { if (log.isDebugEnabled()) log.debug("Getting all the billing entries for last month for user with ID " + id); //String queryString = "select billingEntry from BillingEntry as billingEntry where billingEntry>=:firstOfLastMonth and billingEntry.timestamp<:firstOfCurrentMonth and billingEntry.user=:user"; String queryString = "select be from BillingEntry as be join be.user as user where user.id=:id and be.timestamp>=:firstOfLastMonth and be.timestamp<:firstOfCurrentMonth"; //This parameter will be the start of the last month ie. start of billing cycle SearchParameter firstOfLastMonth = new SearchParameter(); firstOfLastMonth.setTemporalType(TemporalType.DATE); //this parameter holds the start of the CURRENT month - ie. end of billing cycle SearchParameter firstOfCurrentMonth = new SearchParameter(); firstOfCurrentMonth.setTemporalType(TemporalType.DATE); Query query = super.entityManager.createQuery(queryString); query.setParameter("firstOfCurrentMonth", getFirstOfCurrentMonth()); query.setParameter("firstOfLastMonth", getFirstOfLastMonth()); query.setParameter("id", id); List<BillingEntry> entries = query.getResultList(); return entries; } public MonthlyBill createXMLBillForUser(Long id, Collection<BillingEntry> billingEntries) { BillingHistoryManager manager = ManagerFactory.getBillingHistoryManager(); UserManager userManager = ManagerFactory.getUserManager(); MonthlyBill mb = new MonthlyBill(); User user = userManager.getUser(id); mb.setUser(user); mb.setTimestamp(new Date()); Set<BillingEntry> entries = new HashSet<BillingEntry>(); entries.addAll(billingEntries); String xml = createXmlForMonthlyBill(user, entries); mb.setXmlBill(xml); mb.setBillingEntries(entries); MonthlyBill bill = (MonthlyBill) manager.saveOrUpdate(mb); return bill; } Help with this issue would be greatly appreciated as its been wracking my brain for weeks now! Thanks in advance, Gearoid.

    Read the article

  • A quick over view of facebook's db?

    - by Matt
    Hey guys I find it hard to believe that Facebook uses simple sql, surely it would use some other method but lets assume for now it does use sql how would the code assimilating the 'wall' work? Lets say that there is three tables (just for the example) Friends: id (entry key) - uid(your id) - fid (your mates' id) Wall:id (entry key) - username - comment - time - commentcount comments: id (entry key) - wid (wall id (original comment)) - reply - time Lets forget about the like part and report etc, as well as mod things (ip, ban etc.) How would this work? Select wall.id, wall.username, wall.comment, wall.time, wall.commentcount, comments.wid, comments.reply, comments.time FROM wall inner join comments ON wall.id=comments.wid ORDER BY wall.time; That's your own wall but how do they get friend's? A heap of unions?

    Read the article

  • implmenting 1 to n mapping for ORM c++

    - by karan
    I am writing a project where i need to implment a stripped down version of an ORM solution in c++. I am struck in implmenting 1-n relationships for the same. For instance, if following are the classes: class A { } class B { std::list _a_list; } I have provided load/save menthods for loading/saving to the db. Now, if i take the case of B : Say , for the following workflow : 1 entry from _a_list is removed 1 entry from _a_list is modified 1 entry is added to _a_list Now, i need to update the db using something like "b.save()". So, what would be the best way to save the changes,i.e, identify the additions, deletions and updations to _a_list.

    Read the article

  • C++ template class error with operator ==

    - by Tommy
    Error: error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const entry' (or there is no acceptable conversion) The function: template <class T, int maxSize> int indexList<T, maxSize>::search(const T& target) const { for (int i = 0; i < maxSize; i++) if (elements[i] == target) //ERROR??? return i; // target found at position i // target not found return -1; } indexList.h indexList.cpp Is this suppose to be an overloaded operator? Being a template class I am not sure I understand the error? Solution- The overload function in the class now declared const: //Operators bool entry::operator == (const entry& dE) const <-- { return (name ==dE.name); }

    Read the article

  • Implementing 1 to n mapping for ORM c++

    - by karan
    I am writing a project where I need to implement a stripped down version of an ORM solution in C++. I am struck in implementing 1-n relationships for the same. For instance, if the following are the classes: class A { ... } class B { ... std::list<A> _a_list; ... } I have provided load/save methods for loading/saving to the db. Now, if I take the case of B and the following workflow: 1 entry from _a_list is removed 1 entry from _a_list is modified 1 entry is added to _a_list Now, I need to update the db using something like "b.save()". So, what would be the best way to save the changes, i.e, identify the additions, deletions and updates to _a_list.

    Read the article

  • Problem with auto increment primary key (MySQL).

    - by mathon12
    I have 2 tables each using other's primary key as a foreign key. The primary keys for both are set to auto_increment. The problem is, when I try to create and entry into one of the tables, I have no idea what the primary key of the entry is and can't figure out what to put in the other table as a foreign key. What should I do? Do I drop auto_increment altogether and cook up a unique identifier for each entry so I can use it to address the created entries? I'm using PHP, if that's relevant. Thanks.

    Read the article

  • MySQL Select Statement - Two Tables, Sort One Table by Count of Other Table

    - by Robert Boka
    So I have built a voting system for a custom post system i wrote. I want to be able to sort by "most voted", "Most liked", etc. I have two tables. Entry: ID, Title, Post Vote: ID, EntryID, Result I want to be able to query the vote table for each entry and see how many vote's there are, and then sort the entry's by how many vote's each table had. I have messed around with joins, etc. and cannot seem to figure it out. Any suggestions?

    Read the article

  • Implement dictionary using java

    - by ahmad
    Task Dictionary ADT The dictionary ADT models a searchable collection of key-element entries Multiple items with the same key are allowed Applications: word-definition pairs Dictionary ADT methods: find(k): if the dictionary has an entry with key k, returns it, else, returns null findAll(k): returns an iterator of all entries with key k insert(k, o): inserts and returns the entry (k, o) remove(e): remove the entry e from the dictionary size(), isEmpty() Operation Output Dictionary insert(5,A) (5,A) (5,A) insert(7,B) (7,B) (5,A),(7,B) insert(2,C) (2,C) (5,A),(7,B),(2,C) insert(8,D) (8,D) (5,A),(7,B),(2,C),(8,D) insert(2,E) (2,E) (5,A),(7,B),(2,C),(8,D),(2,E) find(7) (7,B) (5,A),(7,B),(2,C),(8,D),(2,E) find(4) null (5,A),(7,B),(2,C),(8,D),(2,E) find(2) (2,C) (5,A),(7,B),(2,C),(8,D),(2,E) findAll(2) (2,C),(2,E) (5,A),(7,B),(2,C),(8,D),(2,E) size() 5 (5,A),(7,B),(2,C),(8,D),(2,E) remove(find(5)) (5,A) (7,B),(2,C),(8,D),(2,E) find(5) null (7,B),(2,C),(8,D),(2,E) Detailed explanation: NO Specific requirements: please Get it done i need HELP !!!

    Read the article

  • How to By Pass Request Validation

    - by GIbboK
    Hi, I have a GridView and I need update some data inserting HTML CODE; I would need this data been stored encoded and decoded on request. I cannot in any way disable globally "Request Validation" and not even at Page Level, so I would need a solution to disable "Request Validation" at Control Level. At the moment I am using a script which should Html.Encode every value being update, butt seems that "Request Validation" start its job before event RowUpdating, so I get the Error "Page A potentially dangerous Request.Form ... ". Any idea how to solve it? Thanks protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { foreach (DictionaryEntry entry in e.NewValues) { e.NewValues[entry.Key] = Server.HtmlEncode(entry.Value.ToString()); } PS I USE Wweb Controls not MVC

    Read the article

  • ASP.Net delete record audit trigger

    - by Germ
    Suppose you have the following... A ASP.NET web application that calls a stored procedure to delete a record. The table has a trigger on it that will insert an audit entry each time a record is deleted. I want to be able to record in the audit entry the person who deleted the record. What would be the best way to go about achieving this? I know I could remove the trigger and have the delete stored procedure insert the audit entry prior to deleting but are there other recommeded alternative?

    Read the article

  • How can I avoid mutable variables in Scala when using ZipInputStreams and ZipOutpuStreams?

    - by pr1001
    I'm trying to read a zip file, check that it has some required files, and then write all valid files out to another zip file. The basic introduction to java.util.zip has a lot of Java-isms and I'd love to make my code more Scala-native. Specifically, I'd like to avoid the use of vars. Here's what I have: val fos = new FileOutputStream("new.zip"); val zipOut = new ZipOutputStream(new BufferedOutputStream(fos)); while (zipIn.available == 1) { val entry = zipIn.getNextEntry if (entryIsValid(entry)) { val fos = new FileOutputStream("subdir/" + entry.getName()); val dest = new BufferedOutputStream(fos); // read data into the data Array var data: Array[Byte] = null var count = zip.read(data) while (count != -1) { dest.write(data, 0, count) count = zip.read(data) } dest.flush dest.close } }

    Read the article

  • Removing Redundant Data from a List<T>

    - by Mark
    I have a List of objects which are ordered. I would like to remove redundant objects where redundant does not necessarily mean duplicate. Here is an example: List<Point> points = new List<Point> { new Point(0, 10), new Point(1, 12), new Point(2, 16), new Point(3, 16), new Point(4, 16), new Point(5, 13), new Point(6, 16), }; I am interested in removing the new Point(3, 16) entry because it doesn't provide useful information; I already know that the element at 2=16 and the element at 4=16. The information that 3=16 doesn't do me any good in my application (because I already have the bounds {2,4}=16), so I would like to remove that entry. I'd also like to not that I want to keep the 5th and 6th entry because there are not consecutive entries where Y=16. Is there a slick way to do this with linq?

    Read the article

  • Enter purchase order received quantity by code

    - by user733916
    In purchase order form - Line - Tab Quantity, there is Received, Delivery Reminder and Ordered. I want to be able to entry those field by X++ code, because currently our company still entry data into old system. I can retrieve the arrival purchase order goods data from that old system, then I want to entry those retrieved data by code into Axapta. What table and field should I consider when doing that? What functions available to easily update each PO lines received quantity? Sample Code is nice.

    Read the article

  • git, SSH_ASKPASS on windows

    - by Martin Schreiber
    I am writing a graphical git frontend for Linux and Windows (MSEgit) based on MSEide+MSEgui. MSEgit has an internal console window which communicates with git by pipes. On Linux it uses a PTY so SSH asks for key unlocking passwords on the PTY. On Windows I wrote a small password entry application and set the SSH_ASKPASS environment variable accordingly. SSH calls the password application if git is started with CreateProcess() dwCreationFlags DETACHED_PROCESS set but the password entry window will not be focused, its taskbar icon flashes instead. SSH does not run the password application if FreeConsole() is called to be sure that there is no attached console to MSEgit and git is started without DETACHED_PROCESS but CREATE_NO_WINDOW instead. I assume a Windows equivalent of POSIX setsid() should be called. How can I force SSH to use SSH_ASKPASS without the DETACHED_PROCESS flag? If this is not possible, how can I ensure that the password entry window is focused?

    Read the article

  • importing data using get or create - identity error 1062

    - by hamackey
    I am importing data from a mssql database into mysql. Works except when it encounters the id of a previous entry. id is unique. I need to get entries that already exist so that they can be placed in the work of the day. Error is IntegrityError: (1062, "Duplicate entry '001355338' for key 2") This entry is already in the database. I need it entered for that day, but can not have it added to the table. It is already there. def handle(self, *args, **options): 59 #patients_local = Patient.objects.all() 60 #attendings_local = Attending.objects.all() 61 connection = pyodbc.connect("XXXXXXXXXXX") 62 cursor = connection.cursor() 63 cursor.execute(COMMAND) 64 rows = cursor.fetchall() 65 for row in rows: 66 # get_or_create returns (object, boolean) 67 p, created = Patient.objects.get_or_create( 68 first_name = row.Firstname, 69 middle_name = '', 70 last_name = row.Lastname, 71 id = row.id, 72 )

    Read the article

  • Accessing items from a dictionary using pickle efficiently in Python

    - by user248237
    I have a large dictionary mapping keys (which are strings) to objects. I pickled this large dictionary and at certain times I want to pull out only a handful of entries from it. The dictionary has usually thousands of entries total. When I load the dictionary using pickle, as follows: from cPickle import * # my dictionary from pickle, containing thousands of entries mydict = open(load('mypickle.pickle')) # accessing only handful of entries here for entry in relevant_entries: # find relevant entry value = mydict[entry] I notice that it can take up to 3-4 seconds to load the entire pickle, which I don't need, since I access only a tiny subset of the dictionary entries later on (shown above.) How can I make it so pickle only loads those entries that I have from the dictionary, to make this faster? Thanks.

    Read the article

  • Using a trigger to record audit information vs. stored procedure

    - by Germ
    Suppose you have the following... An ASP.NET web application that calls a stored procedure to delete a record. The table has a trigger on it that will insert an audit entry each time a record is deleted. I want to be able to record in the audit entry the username of who deleted the record. What would be the best way to go about achieving this? I know I could remove the trigger and have the delete stored procedure insert the audit entry prior to deleting but are there any other recommeded alternative? If a username was passed as a parameter to the delete stored procedure, is there anyway to get this value in the trigger that's excuted when the record is deleted? I'm just throwing this out there...

    Read the article

  • Using xval with fields containing periods

    - by JP
    Hello, I have been using xVal with success for a while but this evening ran into an issue where a field containing a period would not be validated (client or server-side). I am using ASP.NET MVC2 and need to use the period syntax in cases where I am model binding to a list. In the below example I am using a textbox for the sake of simplicity: xVal.AttachValidator(null, { "Fields": [{ "FieldName": "entry[622592].Value", "FieldRules": [{ "RuleName": "Required", "RuleParameters": {}}]}] }, {}) <input type="text" class="text" name="entry[622592].Value"/> If I replace both instances of "entry[622592].Value" to something trivial like "test" then the validation works successfully, but if i leave it this way the validation never appears to fire... Has anyone run into this issue? Thanks in advance!

    Read the article

  • apache Digester: Unexspected NoSuchMethodException on addSetNestedProperties

    - by qstorm
    Hi, I have a problem using Digester and I hope you can help me. I have the following Bean: public class MyEntry { private String entityID; public String getEntityID() { return this.entityID; } public void setEntityID(final String entityID) { this.entityID = entityID; } } And the following XML structure: <entries> <entry> <MyID> 24309LAGH1 </MyID> </entry> </entries> I use the addSetNestedProperties(…) method of the digester API: digester.addSetNestedProperties("entries/entry", "MyID", "entryID"); The following exception occurs: java.lang.NoSuchMethodException: Bean has no property named MyID Why is digester searching for a property named “MyID”? I specified “entryID” as bean property accorsing to the digester API Thanks :) Best regards QStorm

    Read the article

  • JPA GeneratedValue with GenerationType.TABLE does a big jump after jvm restart

    - by joeduardo
    When I start my server and add an entry, the generated id will start with 1, 2, so on and so forth. After a restart, adding an entry would generate an id like 32,xxx. Another restart and adding of entry would generate an id like 65,xxx. I don't know why this is happening. Here's a snippet of the annotation I'm using for my id. I'm using Hibernate. @Id @GeneratedValue(strategy = GenerationType.TABLE) private Long id;

    Read the article

  • What is the best way to log a user in programatically in ExpressionEngine

    - by bjohnb
    I'm building an app that allows the app to hit an ACT url which then triggers a module method to create a new entry using the ExpressionEngine API. However, as there is no user logged in / loggin in, it is not allowed to submit an entry to a channel. What is the best way to do this. Bypass the EE api and submit the entry manually, or log a user in progamatically..but then how would that work with sessions etc etc? If the answer is to "log a user in" it would be great to see a code sample if possible. Thanks!

    Read the article

  • SQLite: Simple DELETE statement did not work

    - by user186446
    I have a table MRU, that has 3 columns. (VALUE varchar(255); TYPE varchar(20); DT_ADD datetime) This is a table simply storing an entry and recording the date time it was recorded. What I wanted to do is: delete the oldest entry whenever I add a new entry that exceeds a certain number. here is my query: delete from MRU where type = 'FILENAME' ORDER BY DT_ADD limit 1; The query returns an error. Thanks

    Read the article

  • php web based portal authentication through IP.

    - by user434885
    i have a web portal running which involves basic data entry. The issue being that this is highly sensitive data. And the credibility of the data entry personel is very low. Therefore i have implemented recording of IP when an entry is made. The Problem i am facing is if this if this person starts forwarding his IP from a proxy server then i am unable to track authenticity of the data. How do i detect if the IP forwarding is happening/ get the real ip address of the person.

    Read the article

  • Building an HTML5 App with ASP.NET

    - by Stephen Walther
    I’m teaching several JavaScript and ASP.NET workshops over the next couple of months (thanks everyone!) and I thought it would be useful for my students to have a really easy to use JavaScript reference. I wanted a simple interactive JavaScript reference and I could not find one so I decided to put together one of my own. I decided to use the latest features of JavaScript, HTML5 and jQuery such as local storage, offline manifests, and jQuery templates. What could be more appropriate than building a JavaScript Reference with JavaScript? You can try out the application by visiting: http://Superexpert.com/JavaScriptReference Because the app takes advantage of several advanced features of HTML5, it won’t work with Internet Explorer 6 (but really, you should stop using that browser). I have tested it with IE 8, Chrome 8, Firefox 3.6, and Safari 5. You can download the source for the JavaScript Reference application at the end of this article. Superexpert JavaScript Reference Let me provide you with a brief walkthrough of the app. When you first open the application, you see the following lookup screen: As you type the name of something from the JavaScript language, matching results are displayed: You can click the details link for any entry to view details for an entry in a modal dialog: Alternatively, you can click on any of the tabs -- Objects, Functions, Properties, Statements, Operators, Comments, or Directives -- to filter results by type of syntax. For example, you might want to see a list of all JavaScript built-in objects: You can login to the application to make modification to the application: After you login, you can add, update, or delete entries in the reference database: HTML5 Local Storage The application takes advantage of HTML5 local storage to store all of the reference entries on the local browser. IE 8, Chrome 8, Firefox 3.6, and Safari 5 all support local storage. When you open the application for the first time, all of the reference entries are transferred to the browser. The data is stored persistently. Even if you shutdown your computer and return to the application many days later, the data does not need to be transferred again. Whenever you open the application, the app checks with the server to see if any of the entries have been updated on the server. If there have been updates, then only the updates are transferred to the browser and the updates are merged with the existing entries in local storage. After the reference database has been transferred to your browser once, only changes are transferred in the future. You get two benefits from using local storage. First, the application loads very fast and works very fast after the data has been loaded once. The application does not query the server whenever you filter or view entries. All of the data is persisted in the browser. Second, you can browse the JavaScript reference even when you are not connected to the Internet (when you are on the proverbial airplane). The JavaScript Reference works as an offline application for browsers that support offline applications (unfortunately, not IE). When using Google Chrome, you can easily view the contents of local storage by selecting Tools, Developer Tools (CTRL-SHIFT I) and selecting Storage, Local Storage: The JavaScript Reference app stores two items in local storage: entriesLastUpdated and entries. HTML5 Offline App For browsers that support HTML5 offline applications – Chrome 8 and Firefox 3.6 but not Internet Explorer – you do not need to be connected to the Internet to use the JavaScript Reference. The JavaScript Reference can execute entirely on your machine just like any other desktop application. When you first open the application with Firefox, you are presented with the following warning: Notice the notification bar that asks whether you want to accept offline content. If you click the Allow button then all of the files (generated ASPX, images, CSS, JavaScript) needed for the JavaScript Reference will be stored on your local computer. Automatic Script Minification and Combination All of the custom JavaScript files are combined and minified automatically whenever the application is built with Visual Studio. All of the custom scripts are contained in a folder named App_Scripts: When you perform a build, the combine.js and combine.debug.js files are generated. The Combine.config file contains the list of files that should be combined (importantly, it specifies the order in which the files should be combined). Here’s the contents of the Combine.config file:   <?xml version="1.0"?> <combine> <scripts> <file path="compat.js" /> <file path="storage.js" /> <file path="serverData.js" /> <file path="entriesHelper.js" /> <file path="authentication.js" /> <file path="default.js" /> </scripts> </combine>   jQuery and jQuery UI The JavaScript Reference application takes heavy advantage of jQuery and jQuery UI. In particular, the application uses jQuery templates to format and display the reference entries. Each of the separate templates is stored in a separate ASP.NET user control in a folder named Templates: The contents of the user controls (and therefore the templates) are combined in the default.aspx page: <!-- Templates --> <user:EntryTemplate runat="server" /> <user:EntryDetailsTemplate runat="server" /> <user:BrowsersTemplate runat="server" /> <user:EditEntryTemplate runat="server" /> <user:EntryDetailsCloudTemplate runat="server" /> When the default.aspx page is requested, all of the templates are retrieved in a single page. WCF Data Services The JavaScript Reference application uses WCF Data Services to retrieve and modify database data. The application exposes a server-side WCF Data Service named EntryService.svc that supports querying, adding, updating, and deleting entries. jQuery Ajax calls are made against the WCF Data Service to perform the database operations from the browser. The OData protocol makes this easy. Authentication is handled on the server with a ChangeInterceptor. Only authenticated users are allowed to update the JavaScript Reference entry database. JavaScript Unit Tests In order to build the JavaScript Reference application, I depended on JavaScript unit tests. I needed the unit tests, in particular, to write the JavaScript merge functions which merge entry change sets from the server with existing entries in browser local storage. In order for unit tests to be useful, they need to run fast. I ran my unit tests after each build. For this reason, I did not want to run the unit tests within the context of a browser. Instead, I ran the unit tests using server-side JavaScript (the Microsoft Script Control). The source code that you can download at the end of this blog entry includes a project named JavaScriptReference.UnitTests that contains all of the JavaScripts unit tests. JavaScript Integration Tests Because not every feature of an application can be tested by unit tests, the JavaScript Reference application also includes integration tests. I wrote the integration tests using Selenium RC in combination with ASP.NET Unit Tests. The Selenium tests run against all of the target browsers for the JavaScript Reference application: IE 8, Chrome 8, Firefox 3.6, and Safari 5. For example, here is the Selenium test that checks whether authenticating with a valid user name and password correctly switches the application to Admin Mode: [TestMethod] [HostType("ASP.NET")] [UrlToTest("http://localhost:26303/JavaScriptReference")] [AspNetDevelopmentServerHost(@"C:\Users\Stephen\Documents\Repos\JavaScriptReference\JavaScriptReference\JavaScriptReference", "/JavaScriptReference")] public void TestValidLogin() { // Run test for each controller foreach (var controller in this.Controllers) { var selenium = controller.Value; var browserName = controller.Key; // Open reference page. selenium.Open("http://localhost:26303/JavaScriptReference/default.aspx"); // Click login button displays login form selenium.Click("btnLogin"); Assert.IsTrue(selenium.IsVisible("loginForm"), "Login form appears after clicking btnLogin"); // Enter user name and password selenium.Type("userName", "Admin"); selenium.Type("password", "secret"); selenium.Click("btnDoLogin"); // Should set adminMode == true selenium.WaitForCondition("selenium.browserbot.getCurrentWindow().adminMode==true", "30000"); } }   The results for running the Selenium tests appear in the Test Results window just like the unit tests: The Selenium tests take much longer to execute than the unit tests. However, they provide test coverage for actual browsers. Furthermore, if you are using Visual Studio ALM, you can run the tests automatically every night as part of your standard nightly build. You can view the Selenium tests by opening the JavaScriptReference.QATests project. Summary I plan to write more detailed blog entries about this application over the next week. I want to discuss each of the features – HTML5 local storage, HTML5 offline apps, jQuery templates, automatic script combining and minification, JavaScript unit tests, Selenium tests -- in more detail. You can download the source control for the JavaScript Reference Application by clicking the following link: Download You need Visual Studio 2010 and ASP.NET 4 to build the application. Before running the JavaScript unit tests, install the Microsoft Script Control. Before running the Selenium tests, start the Selenium server by running the StartSeleniumServer.bat file located in the JavaScriptReference.QATests project.

    Read the article

< Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >